Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created March 4, 2020 05:32
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/21823723d5fffd4cc065e84ec7aa7a86 to your computer and use it in GitHub Desktop.
Save codecademydev/21823723d5fffd4cc065e84ec7aa7a86 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:
print("You've won and you've got $" + (str(money + bet_amount)) + "!")
return bet_amount
elif coin_outcome != choose_side:
print("You've lost and you've got $" + (str(money - bet_amount)) + ".")
return bet_amount
#Call your game of chance functions here
money += coin_flip(2, 23)
money += coin_flip(1, 34)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment