We have already looked if-elif-else
statements in previously. if-elif-else
requires conditions in order evaluate. These conditions may simple True
, False
or comparisons. The other way is we can define complex conditionals in order to evaluate.
我们已经看了if-elif-else
语句前面。 if-elif-else
需要条件才能进行评估。 这些条件可以是True
, False
或比较。 另一种方法是我们可以定义复杂的条件以便进行评估。
简单条件 (Simple Conditions)
Simple conditions are just single statement conditions where we do not need grouping or multiple or
, and
. We will just check if the value is bigger than 50
in this example.
简单条件只是单条语句条件,在这里我们不需要分组或多个or
, and
。 在此示例中,我们将仅检查该值是否大于50
。
value=55
if(value>50):
print("Value is bigger than 50")
#Value is bigger than 50
![Simple Conditions](https://i-blog.csdnimg.cn/blog_migrate/725cf93fa3b687de8b7d40cd48a9a3a9.png)
多个条件和运算符(Multiple Conditions And Operator)
The first real world usage example of multiple operators/conditions in a single if
will be and
operator. We will specify different conditions and merge them together into single if to return result.
if
是and
运算符,则多个运算符/条件在单个的情况下的第一个实际用法示例。 我们将指定不同的条件,并将它们合并为一个单一的条件