python练习——if条件语句

1.简单条件语句判断

alien_color = 'green' 

if alien_color == 'green':

...     print('5 points!\n')
... else:

...     print("wrong!\n")

2.判断列表元素是否存在

 fruit = ['banana', 'apple', 'orange', 'watermalon']
 if 'apple' in fruit:

...     print('I like banana.\n')

3.多重条件判断

age = 25

     if age < 2 :
...     print('He is a baby.\n')
... elif age >= 2 and age <13 :
...     print('he is a child.\n')
... elif age > 13 and age < 20 :
...     print('He is adolescent.\n')
... else:
...     print('he is an adult.\n')

你可能感兴趣的:(python)