Exercise 1:
gender = input("Please input your gender")
if gender == "female":
age = int(input("Please input your age:"))
if age >= 9 and age <= 12:
print("You can join.")
else:
print("Requirements not met.")
else:
print("Requirements not met.")
Exercise 2:
c = int(input("Please input your French score:"))
m = int(input("Please input your Math score"))
e = int(input("Please input your English score"))
if (c + m + e) >= 280:
print("Excellent!")
print("Please go to Admin Office for gift.")
elif (c + m + e) < 260:
print("Carry on.")
else:
s = int(input("Please input your gym score:"))
if s >= 90:
print("Excellent!")
print("Please go to Admin Office for gift.")
else:
print("Carry on.")
Homework:
import random
print("----Guess Odd Even Number Game----")
start=input("Will you start the game right away?(yes/no)")
if start == 'yes':
rand = random.randint(1,100)
print("Computer generated a random number between 0 and 100.")
number = input("Please guess it is odd or even?(odd/even)")
if((rand%2 == 0 and number == "even") or (rand%2 != 0 and number == "odd")):
print("The generated number is ",rand,"Congratulations. You Win.")
else:
print("The generated number is ",rand,"Sorry. You Lose.")
else:
print("Game quit.")
[…] 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| |____Unit 18 Rock Paper Scissor […]