Skip to content

Instantly share code, notes, and snippets.

@SaraM92
Created September 29, 2020 19:09
Show Gist options
  • Save SaraM92/d3ce1571acc91fddedf6479d0f3b5d62 to your computer and use it in GitHub Desktop.
Save SaraM92/d3ce1571acc91fddedf6479d0f3b5d62 to your computer and use it in GitHub Desktop.
#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