Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created March 3, 2020 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/42097873201da895ac6a6e9f9d49a759 to your computer and use it in GitHub Desktop.
Save codecademydev/42097873201da895ac6a6e9f9d49a759 to your computer and use it in GitHub Desktop.
Codecademy export
import random
money = 100
#Write your game of chance functions here
def coin_flip(choose_side, bet_amount):
coin_outcome = random.randint(1, 2)
if choose_side == 1:
print("You've placed a " + str(bet_amount) + " $ bet and have chosen Heads!")
elif choose_side == 2:
print("You've placed a " + str(bet_amount) + " $ bet and have chosen Tails!")
if coin_outcome == 1:
print("It's Heads!")
elif coin_outcome == 2:
print("It's Tails!")
if coin_outcome == choose_side:
return "You've won and you've got " + (str(money + bet_amount)) + " $!"
elif coin_outcome != choose_side:
return "You've lost and you've got " + (str(money - bet_amount)) + " $."
#Call your game of chance functions here
money += coin_flip(2, 45)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment