Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created August 14, 2020 16:42
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/c54abe88feedf1ebffe06556bf77e133 to your computer and use it in GitHub Desktop.
Save codecademydev/c54abe88feedf1ebffe06556bf77e133 to your computer and use it in GitHub Desktop.
Codecademy export
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