判断
age = 18
if age >= 18:
print('成年')
else:
print('未成年')
多分支判断
多条件判断,如果条件满足就执行对应的代码块,如果条件都不满足就执行else代码块
score = 90
if score >= 90:
print('优秀')
elif score >= 80:
print('良好')
elif score >= 60:
print('及格')
else:
print('不及格')
嵌套判断
判断中嵌套判断
age = 18
if age >= 18:
print('成年')
if age >= 65:
print('老年')
elif age >= 35:
print('中年')
else:
print('青年')
else:
print('未成年')
多条件同时判断
age = 18
if age >= 18 and age <= 65:
print('成年')
elif age >= 65:
print('老年')
else:
print('未成年')