Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created July 19, 2020 02:35
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/2673948cf8c40f64c7fc693a690bc452 to your computer and use it in GitHub Desktop.
Save codecademydev/2673948cf8c40f64c7fc693a690bc452 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(guess, bet):
money = 100
flip = random.randint(1, 2)
1 == "Heads"
2 == "Tails"
win = "You win " + str(bet * 2) + "!" + "You now have " + str((bet *2) + money) + "."
lose = "Sorry, wrong guess. You lose " + str(bet * 2) + "." + " You now have " + str(money - (bet * 2)) + "."
if flip == guess:
return win
if flip != guess:
return lose
#Call your game of chance functions here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment