Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created March 11, 2020 14:38
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/bd948260dcf0999722ff0f813ac9d474 to your computer and use it in GitHub Desktop.
Save codecademydev/bd948260dcf0999722ff0f813ac9d474 to your computer and use it in GitHub Desktop.
Codecademy export
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