Python条件判断

条件判断让程序根据不同情况走不同分支。

if score >= 60:
    print("pass")
else:
    print("fail")

条件通常来自:

  • 比较运算:>, <, ==
  • 逻辑运算:and, or, not
  • 成员判断:in, not in

相关:Python运算符Python代码块与缩进Python循环语句