#πŸ”’ Need Help about a Program

38 messages Β· Page 1 of 1 (latest)

wispy island
#

I want to make a game of slot [like in owo bot text based] so it is like you challenge a specific amount of money you can say there is 60% chance of losing money , 10% of returning of all money , 20% of doubling it , so on how can i do it???
Like the chance part
I am a begginer

tacit ospreyBOT
#

@wispy island

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

strange shale
wispy island
#

Like random module???

strange shale
#

yes

#

but do you know the functions it has?

#

choice, sample, random, randint, etc

wispy island
strange shale
#

Ok, so there's a few ways you can do this

wispy island
#

Tell the simplest

#

Like can i tell how i did it but ig it is not convinent

strange shale
#

well, your percentages only add up to 90%, so what's the last 10 percent?

wispy island
#

You can say like 9% for thrice and 1% for ten times

strange shale
#

!e

import random

chances = []
chances.extend(['lose'] * 60)
chances.extend(['return'] * 10)
chances.extend(['double'] * 20)
chances.extend(['triple'] * 9)
chances.extend(['ten times'] * 1)

print(chances)

tacit ospreyBOT
# strange shale !e ```py import random chances = [] chances.extend(['lose'] * 60) chances.exten...

:white_check_mark: Your 3.12 eval job has completed with return code 0.

['lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'lose', 'return', 'return', 'return', 'return', 'return', 'return', 'return', 'return', 'return', 'return', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'triple', 'triple', 'triple', 'triple', 'triple', 'triple', 'triple', 'triple', 'triple', 'ten times']
strange shale
#

ok, so you can do something like this to populate a list of all available options

#

and if you use random.choice, the percentages are higher for options that appear more

#

the other way to do this is using weights

wispy island
hollow lark
wispy island
strange shale
#

!e

import random

chances = ['lose', 'return', 'double', 'triple', 'ten times']
chance_weights = [60, 10, 20, 9, 1]
print(random.choices(chances, weights=chance_weights, k=1))

tacit ospreyBOT
strange shale
#

the other option is using a weights list

hollow lark
#

I learnt something new from you guys!!

#

Random module

wispy island
#

Ig first method is easy for me

#

Thanks alot

wispy island
# strange shale the other option is using a weights list

But listen i am going to make it like you can play untill you want to quit by typing 'q' so repeating that again and again will extend the list every time or list get resets each time when the loop starts again??
||@strange shale ||

strange shale
wispy island
#

Thanks bye

#

!close

tacit ospreyBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.