Python 7 Levels, L2, Unit 14, Multiple if Statements

Powered By EmbedPress

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.")

dahan1999

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts