-
-
Save codecademydev/c54abe88feedf1ebffe06556bf77e133 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 | |
# Heads and Tails # | |
def game_of_change(bet, ht): | |
money = 100 | |
num = random.randint(1, 10) | |
if num <= 5 and ht == 'Heads': | |
money = money + bet | |
return 'You won ' + str(bet) + ' You have ' + str(money) | |
elif num >= 5 and ht == 'Tails': | |
money = money + bet | |
return 'You won ' + str(bet) + ' You have ' + str(money) | |
else: | |
money = money - bet | |
return 'You lost ' + str(bet) + ' You have ' + str(money) | |
# Call your game of chance functions here | |
game_of_change(10, 'Tails') | |
# ------------------------ # | |
# Cho-Han # | |
def cho_han(bet, odd_even): | |
dice1 = random.randrange(1, 6) | |
dice2 = random.randrange(1, 6) | |
if (int(dice1 + dice2) % 2 == 0) and odd_even == 'Even': | |
print('Even' + ' You won' + str(bet)) | |
elif (int(dice1 + dice2) % 2 != 0) and odd_even == 'Odd': | |
print('Odd' + ' You won' + str(bet)) | |
else: | |
print('You lost' + str(bet)) | |
# Call your game of chance functions here | |
cho_han(10, 'Even') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment