-
Notifications
You must be signed in to change notification settings - Fork 0
/
coffee.py
35 lines (29 loc) · 901 Bytes
/
coffee.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
# Example coffee shop code
small = 2
regular = 5
large = 6
budget = input("How much money do you have? ")
try:
budget = int(budget)
except ValueError:
print("Please enter a number")
exit() # exit vs quit?
if budget > 0:
if budget >= large:
print("You can afford a large coffee")
if budget == large:
print("You have no change")
else:
print("Your change is", budget - large)
elif budget >= regular:
print("You can afford a regular coffee")
if budget == regular:
print("You have no change")
else:
print("Your change is", budget - regular)
elif budget >= small:
print("You can afford a small coffee")
if budget == small:
print("You have no change")
else:
print("Your change is", budget - small)