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

The if...else condition

The if...else condition is pretty much the same as in any other language. If the if condition evaluates to a True value, the code block indented under if is executed. Otherwise, the code block indented under the else block is executed:

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

Let's create a file called if_else.py and see how to use it:

Again, the output here is self-explanatory. In this section of code, we explored the usage of some bitwise operators alongside the if...else code structure. We also used variables, which are to be printed with the print method. %s is a placeholder, and specifies that the value of %s should be replaced by a string variable whose value would come immaterially after the string ends. If we have multiple values to substitute, they can be passed as a tuple such as %(val1,val2,val3):

主站蜘蛛池模板: 祁门县| 海安县| 新邵县| 大港区| 郯城县| 咸阳市| 灵丘县| 鹰潭市| 台江县| 十堰市| 团风县| 万盛区| 遵义市| 富平县| 福泉市| 咸宁市| 社会| 贵定县| 大庆市| 文昌市| 大庆市| 宜昌市| 融水| 尤溪县| 达孜县| 基隆市| 屯留县| 监利县| 高碑店市| 海口市| 安庆市| 新巴尔虎右旗| 博罗县| 昆山市| 遵义县| 宁乡县| 宁阳县| 阜城县| 武冈市| 政和县| 罗平县|