-
-
Save codecademydev/bd948260dcf0999722ff0f813ac9d474 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 | |
#Simulate coin flip | |
def coin_flip(guess): | |
num = random.randint(1, 2) | |
if num == 1: | |
print ("Tails") | |
elif num == 2: | |
print ("Heads") | |
#Check player guess | |
if guess == "Tails" or guess == "tails": | |
return num - 1 | |
elif guess == "Heads" or guess == "heads": | |
return num + 1 | |
if num == 0: | |
print ("You guessed Tails and you were right!") | |
elif num == 3: | |
print ("You guessed Heads and you were right!") | |
elif num == 1: | |
print ("You guessed Tails and you were wrong.") | |
elif num == 2: | |
print ("You guessed Heads and you were wrong.") | |
#Call your game of chance functions here | |
coin_flip("tails") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment