- Hands-On Penetration Testing with Python
- Furqan Khan
- 123字
- 2021-07-02 14:13:53
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:

推薦閱讀
- Android應用程序開發(fā)與典型案例
- Mastering SVG
- SQL語言從入門到精通
- Access 2010數(shù)據(jù)庫基礎與應用項目式教程(第3版)
- 大模型RAG實戰(zhàn):RAG原理、應用與系統(tǒng)構建
- D3.js 4.x Data Visualization(Third Edition)
- C#應用程序設計教程
- 從零開始學Linux編程
- Microsoft Azure Storage Essentials
- Mastering Git
- 圖數(shù)據(jù)庫實戰(zhàn)
- PrimeFaces Blueprints
- 進入IT企業(yè)必讀的324個Java面試題
- 虛擬現(xiàn)實建模與編程(SketchUp+OSG開發(fā)技術)
- 從零開始學Unity游戲開發(fā):場景+角色+腳本+交互+體驗+效果+發(fā)布