-
-
Save codecademydev/21823723d5fffd4cc065e84ec7aa7a86 to your computer and use it in GitHub Desktop.
Codecademy export
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 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