Exercise 1:
score = int(input("Please input your score:"))
if score >= 90:
print("Excellent!")
elif score >= 80 :
print("Good!")
elif score >= 60 :
print("Qualified.")
else:
print("Need Improvement.")
print("Test")
Exercise 2:
money = int(input("Please total cost:"))
if money >= 500:
print("20% discount is applied,your final cost is $",(money*0.8))
elif money >= 300:
print("10% discount is applied,your final cost is $",(money*0.9))
elif money >= 100:
print("$10 off is applied,your final cost is $",(money-10))
else:
print("No discount is applied,your final cost is $",money)
Homework:
import random
rand = random.randint(1,3)
if rand == 1:
print("Enemy shows up left.")
elif rand == 2:
print("Enemy shows up front.")
else:
print("Enemy shows up right.")
direction = input("Please input direction of shooting:")
if (rand == 1 and direction == "a") or (rand == 2 and direction =="w") or (rand == 3 and direction == "d"):
print("Bingo. You hit enemy.")
else:
print("You missed.")
[…] 11 Logical Operators| |____Unit 12 Priority of Operators| |____Unit 13 if else statement| |____Unit 14 Multiple if Statements| |____Unit 15 Nested if Statements| |____Unit 16 Practice| |____Unit 17 Rock Paper Scissor Shoot I| […]