-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq3.py
48 lines (43 loc) · 1.24 KB
/
q3.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
38
39
40
41
42
43
44
45
46
47
48
#Q3 Labfinalpractice
point = 100
while True:
c,p = input("Command: ").split()
if c == "done" and p == "0":
break
p = int(p)
if p > 0:
if c == "P":
earn = p//50 #Floor division
point += earn
print("You earned %d points"%earn)
print("Your accumulated points = %d points"%point)
elif c == "R":
if point > p:
point -= p
print("You redeemed %d points"%p)
print("Your accumulated points = %d points"%point)
else:
print("Not enough points")
else:
print("Invalid command")
else:
print("Invalid command")
#Thun's solution
# b=100
# while True:
# x,y=input('Command: ').split()
# y=int(y)
# if x=="done" and y==0:
# break
# if x == "P" and y>=0:
# b+=y//50
# print("You earned",y//50,"points\nYour accumulated points =",b,"points")
# continue
# if x == "R" and y>=0 and b-y>=0:
# b-=y
# print("You redeemed",y,"points\nYour accumulated points =",b,"points")
# continue
# if x == "R" and y>=0 and b-y<0:
# print("Not enough points")
# continue
# print("Invalid command")