第5章 if语句

------------恢复内容开始------------

5-3外星人颜色#1:

#5-3
alien_color ='green' if alien_color =='green': print('Your get 5 points')

  

#5-3
alien_color ='yellow' if alien_color =='green': print('Your get 5 points')

5-4外星人颜色#2:

#5-4
alien_color ='green' if alien_color =='green': print('Your get 5 points') else: print('Your get 10 points')

  

#5-4
alien_color ='yellow' if alien_color =='green': print('Your get 5 points') else: print('Your get 10 points')

5-5外星人颜色#3:

#5-5
alien_color ='green'
if alien_color =='green':
    print('Your get 5 points')
elif  alien_color =='yellow':
    print('Your get 10 points')
else:
    print('Your get 15 points')

5-6人生的不同阶段:

#5-6
age = 20
if age < 2:
    print('He is baby')
elif age < 4:
    print('He is toddlering')
elif age <13:
    print('He is children')
elif age <20:
    print('He is teenagers')
elif age <65:
    print('He is adult')
else:
    print('He is oldman')

5-7喜欢的水果:

#5-7
favorite_fruits =['apple','cheery','banana']
if 'apple' in favorite_fruits:
    print('You really like apple')
elif  'cheery' in favorite_fruits:
    print('You really like cheery')
elif 'banana' in favorite_fruits:
    print('You really like banana')

  

上一篇:react项目中CSS继承(CSS样式复用)


下一篇:FZU1022 三色二叉树