官术网_书友最值得收藏!

The if...elif condition

The if...elif ladder, popularly known as if...else if in other programming languages such as C, C ++, and Java, has the same function in Python. An if condition let's us specify a condition alongside the else part of the code. Only if the condition is true is the section proceeding the conditional statement executed:

a=44
b=66
if a > b:
print("a is Greater")
elif b > a:
print("B is either Greater or Equal")
else:
print("A and B are equal")
print("End")

It must be noted that the third else in the preceding code snippet is optional. Even if we don't specify it, the code works just fine:

Let's create a file named if_el_if.py, and see how this can be used:

主站蜘蛛池模板: 大同市| 靖安县| 葵青区| 兴仁县| 叙永县| 区。| 苏尼特左旗| 息烽县| 右玉县| 灵丘县| 民乐县| 前郭尔| 塘沽区| 曲周县| 丽江市| 廉江市| 收藏| 九龙城区| 封开县| 富平县| 上蔡县| 敖汉旗| 定西市| 临桂县| 五大连池市| 辉南县| 红河县| 桑植县| 沈阳市| 凤冈县| 磴口县| 上栗县| 夏津县| 紫金县| 安丘市| 紫阳县| 彩票| 四子王旗| 师宗县| 凯里市| 阿拉尔市|