https://www.codecademy.com/practice/projects/games-of-chance
below is the code
import random
money = 100
#num = random.randint(1, 10)
#Write your game of chance functions here
# heads and tails game
heads = 1
tails = 2
bet = random.randint(heads, tails)
def coin_flip(bet_money,call):
if bet == call:
return bet_money
else:
return -bet_money
print(coin_flip(10,heads))
#money += coin_flip(10,heads)
#print(money)
#Call your game of chance functions here
#cho_han
dice_1 = random.randint(1,6)
dice_2 = random.randint(1,6)
dice_sum = dice_1 + dice_2
def cho_ban(call,bet):
if dice_sum%2 == 0 and call == "even":
return bet
if dice_sum%2 != 0 and call == "odd":
return bet
else:
return -bet
print(cho_ban("even",20))
#money += cho_ban("even",20)
#print(money)
#card-game
def card_game(p1_bet,p2_bet):
p1 = random.randint(1,10)
p2 = random.randint(1,10)
if p1>p2:
return p2_bet
elif p2>p1:
return 0-p1_bet
else:
return 0
print(card_game("10","15"))
#money += card_game("10","15")
#print(money)
#roulette
r_num = random.randint(0,100)
def roulette_guess(guess,bet_r):
if r_num%2 ==0 and guess == "even":
return bet_r*2
elif r_num%2 != 0 and guess == "odd":
return bet_r*2
elif r_num == guess:
return r_num * 35
elif r_num == 0:
return -r_num
else:
return -r_num
print(roulette_guess("odd",6))
ERROR:
Traceback (most recent call last):
File “script.py”, line 49, in
print(card_game(“10”,“15”))
File “script.py”, line 46, in card_game
return -p1_bet
TypeError: bad operand type for unary -: ‘str’
PLEASE HELP ME WITH THIS