- 条件判断
python 中的逻辑运算符号: 与 and, 或 or, 非 not。
python中使用if - elif - else来实现条件判断,相当于java中的if - else if - else,而且同样可以嵌套使用。
score = 80
if score < 60:
print("failed")
elif 60 <= score < 80: # 等于 60 <= score and score < 80
print("good")
else:
print("excellent")
结果: