Created
September 29, 2020 19:09
-
-
Save SaraM92/d3ce1571acc91fddedf6479d0f3b5d62 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Import needed libraries | |
import random | |
N = int(input("How many times do you want to play?")) # no of times you will play the game | |
start_money= 10 | |
money = start_money | |
for i in range(N): | |
money -= 1 # pay for the game | |
black = random.randint(1, 6) # throw black | |
green = random.randint(1, 6) # throw green | |
if black > green: # success? | |
money += 2 # get awarded | |
#Calulate the gain or loss after the trials | |
gain = money - start_capital | |
gain_per_game = gain/float(N) | |
print('Gain per game in the long run:', gain_per_game) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment