-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoinflip.py
37 lines (26 loc) · 1.24 KB
/
coinflip.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#coinflip
import os
def coinflipFunc():
flip = input("Heads or Tails? ").lower()
if flip in ["heads", "tails"]:
bet = int(input("How much? "))
if isinstance(float(bet), (int, float)):
import random
x = random.randint(1, 2)
isEven = (x % 2 == 0)
if isEven:
print("Heads,")
if flip == "heads":
print("you won $" + str(bet) + "!")
if flip == "tails":
print("you lost $" + str(bet) + "!")
if isEven == False:
print("Tails,")
if flip == "heads":
print("you lost $" + str(bet) + "!")
if flip == "tails":
print("you won $" + str(bet) + "!")
else:
print("That wasn't a choice, silly!")
coinflipFunc()
os.system("pause")