-
-
Save codecademydev/b94adb034903341d0d63ed8e24eb030c 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 | |
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