Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created March 10, 2020 21:00
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/b94adb034903341d0d63ed8e24eb030c to your computer and use it in GitHub Desktop.
Save codecademydev/b94adb034903341d0d63ed8e24eb030c to your computer and use it in GitHub Desktop.
Codecademy export
import random
money = 100
def coin_flip(guess, bet):
c_num = random.randint(1,2)
if bet > money:
print("You don't have enough money.")
elif guess == ("Heads" or "heads") and c_num == 1:
current_cash = money + bet
print("Coin flipped to Heads! Congrats, you've won $" +str(bet)+ ".00. Your current balance is $" +str(current_cash)+ ".00." )
elif guess == ("Tails" or "tails") and c_num == 2:
current_cash = money + bet
print("Coin flipped to Tails! Congrats, you've won $" +str(bet)+ ".00. Your current balance is $" +str(current_cash)+ ".00." )
elif guess == ("Heads" or "heads") and c_num == 2:
current_cash = money - bet
print("Coin flipped to Tails! Bummer, you lost $" +str(bet)+ ".00. Your current ballance is $" +str(current_cash)+ ".00." )
elif guess == ("Tails" or "tails") and c_num == 1:
current_cash = money - bet
print("Coin flipped to Heads! Bummer, you lost $" +str(bet)+ ".00. Your current balance is $" +str(current_cash)+ ".00." )
def cho_han(guess, bet):
roll= random.randint(1, 12)
even = roll % 2 == 0
odd = roll % 2 != 0
if bet > money:
print("You don't have enough money.")
elif guess == ("Odd" or "odd") and roll == odd:
current_cash = money + bet
print("You bet $" +str(bet)+ ".00 on Odd. You rolled " +str(roll)+ ". Congrats! You now have $" +str(current_cash)+ ".00.")
elif guess == ("Even" or "even") and roll == even:
current_cash = money + bet
print("You bet $" +str(bet)+ ".00 on Even. You rolled " +str(roll)+ ". Congrats! You now have $" +str(current_cash)+ ".00.")
elif guess == ("Odd" or "odd") and roll == even:
current_cash = money - bet
print("You bet $" +str(bet)+ ".00 on Odd. You rolled " +str(roll)+ ". Dang! You now have $" +str(current_cash)+ ".00.")
elif guess == ("Even" or "even") and roll == odd:
current_cash = money - bet
print("You bet $" +str(bet)+ ".00 on Even. You rolled " +str(roll)+ ". Dang! You now have $" +str(current_cash)+ ".00.")
cho_han("Odd", 40)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment