5-3 外星人颜色#1
alien_color = 'green'
if alien_color == 'green':
print("You got 5 points.")
alien_color = 'yellow'
if alien_color == 'green':
print("You got 5 points.")
5-4 外星人颜色#2
alien_color = 'red'
if alien_color == 'green':
print("You got 5 points.")
else:
print("You got 10 points.")
alien_color = 'red'
if alien_color == 'green':
print("You got 5 points.")
if alien_color == 'yellow' or alien_color == 'red':
print("You got 10 points.")
5-5 外星人颜色#3
alien_color = 'green'
if alien_color == 'green':
print("You got 5 points.")
print("\n要想人生过得去,头上就得带点绿。")
elif alien_color == 'yellow':
print("You got 10 points.")
elif alien_color == 'red':
print("You got 15 points.")
alien_color = 'yellow'
if alien_color == 'green':
print("You got 5 points.")
elif alien_color == 'yellow':
print("You got 10 points.")
print("\n搞黄色?")
elif alien_color == 'red':
print("You got 15 points.")
alien_color = 'red'
if alien_color == 'green':
print("You got 5 points.")
elif alien_color == 'yellow':
print("You got 10 points.")
elif alien_color == 'red':
print("You got 15 points.")
print("\n映日荷花别样红")
5-6 人生的不同阶段
age = 15
if age < 2:
print("婴儿")
elif age > 2 and age < 4:
print("蹒跚学步")
elif age > 4 and age < 13:
print("儿童")
elif age > 13 and age < 20:
print("青少年")
elif age > 20 and age < 65:
print("成年人")
elif age >= 65:
print("老年人")
5-7 喜欢的水果
favorite_fruits = ['apple', 'banana', 'cherry']
if 'apple' in favorite_fruits:
print("You really like apples!")
if 'banana' in favorite_fruits:
print("You really like bananas!")
if 'cherry' in favorite_fruits:
print("You really like cherries!")
if 'grape' in favorite_fruits:
print("You really like grapes!")
if 'lemon' in favorite_fruits:
print("You really like lemons!")