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

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):

主站蜘蛛池模板: 兴仁县| 肇源县| 始兴县| 宾阳县| 佳木斯市| 临江市| 福鼎市| 金乡县| 夏邑县| 电白县| 仁化县| 永嘉县| 绥中县| 伊春市| 科技| 台南市| 青岛市| 冀州市| 米泉市| 乳山市| 井陉县| 涪陵区| 历史| 天镇县| 石嘴山市| 苗栗县| 洪泽县| 德保县| 南京市| 资中县| 泰安市| 瑞丽市| 彰武县| 秭归县| 康乐县| 定远县| 平昌县| 东乡族自治县| 碌曲县| 海原县| 彰化市|