Reputation: 51
How would you create a script to determine winning chance of a gambler who bet only on Black/Red slots out of 18 Blacks, 18 Reds, and 2 Greens?
Currently I am stuck with the 50/50 script (Python-2.7) and have absolutely no idea how to add the 5.26% chance of the greens.
Thank you in advance for your answers.
def betting(money, loop_num):
guess = randint(0,1)
result = randint(0,1)
if guess == result:
money += bet*70
main(money, loop_num)
else:
money -= bet
main(money, loop_num)
Upvotes: 0
Views: 250
Reputation: 13691
Try this one:
def betting(money, loop_num):
result = random()
if result <= 0.4737 : // given your 5.26% are right
money += bet*70
main(money, loop_num -1)
else:
money -= bet
main(money, loop_num - 1)
No matter which one he guesses - the probability won't change. Do not forgett to decrese the loop_num, to break the recursion.
Upvotes: 1