-
-
Save codecademydev/786d474e9cc75ad7247efafe6129267d 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 | |
#coin flip | |
def coin_flip(guess, bet): | |
num = random.randint(1,100) | |
if guess == 'Heads' and num <= 50: | |
print("Tails Up You lose") | |
return -bet | |
elif guess == 'Heads' and num >= 50: | |
print("Heads Up You Win") | |
return bet | |
elif guess == 'Tails' and num >= 50: | |
print("Tails up You win") | |
return bet | |
else: | |
print("Heads up you lose") | |
return -bet | |
#han cho | |
def han_cho(guess,bet): | |
num1 = random.randint(1,6) | |
num2 = random.randint(1,6) | |
result = num1 + num2 | |
if guess == "Even" and result % 2 == 0: | |
print("Correct its Even") | |
return bet | |
elif guess == "Odd" and result % 2 != 0: | |
print("Correct its Odd") | |
return bet | |
elif guess == "Odd" and result % 2 == 0: | |
print("inCorrect its Even") | |
return -bet | |
else: | |
print("inCorrect its Odd") | |
return -bet | |
# random card | |
def higher_card(p1_bet, p2_bet): | |
num1 = random.randint(2, 14) | |
num2 = random.randint(2, 14) | |
if num1 > num2: | |
print("Player one Wins") | |
return p1_bet | |
elif num2 > num1: | |
print("Player two Wins") | |
return p2_bet | |
else: | |
print("Draw") | |
return 0 | |
#kinda roulette | |
def roulette(guess, bet): | |
ball = random.randint(0, 36) | |
if guess == ball: | |
Print("You Win it land on Your Number") | |
return 35 | |
elif guess != ball and guess != "Odd" and guess != "Even": | |
print("You lose not your number") | |
return -bet | |
elif guess == "Even" and ball % 2 == 0: | |
print("correct its even") | |
return bet | |
elif guess == "Odd" and ball % 2 != 0: | |
print("correct its Odd") | |
return bet | |
elif guess == "Odd" and ball % 2 == 0: | |
print("incorrect its even") | |
return -bet | |
elif guess == "Even" and ball % 2 != 0: | |
print("incorrect its odd") | |
return -bet | |
else: | |
Print("Ball out of bounds") | |
return 0 | |
#Call your game of chance functions here | |
money += coin_flip("Heads",10) | |
money += han_cho("Odd", 10) | |
money += higher_card(5, 6) | |
money += roulette("Even", 10) | |
print(money) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment