if…else
if …elif…else
有两种形式
if …elif…else
if 性别为男性:
输出男性的体重
...
elif 性别为女性:
输出女性的体重
...
else:
第三种性别的体重
if …elif…elif
if xxx1:
事情1
elif xxx2:
事情2
elif xxx3:
事情3
三目运算
语法:条件成立执行的表达式 if 条件 else 条件不成立执行的表达式
例如:
max = a if a > b else b