div { display:none; }

Trending technologies

#AWS #Azure #Blockchain #IOT #machine learning #Virtual Reality #Analytics #Business Intelligence

Tutorials

Blogs

Python supports below conditions

 

  1. Greater than or equal to: a >= b
  2. Less than or equal to: a <= b
  3. Greater than: a > b
  4. Not Equals: a != b
  5. Less than: a < b
  6. Equals: a == b

if Condition and Indentation : in python we use white space to define the scope of the code.

if b > a:
print("b is greater than a")

Nested IF condition ( Elif ): In Python we can achieve nested if condition using Elif. Simply we can see it’s behave like if…elseif…else…

A = 3
B = 4
if B > A:
print("B is greater than A")
elif A == B:
print("A and B are equal")

Output
B is greater than A
 

Else : if no condition is matched then we can use Else to catch the final statement.

A = 100
B = 10
if b > a:
print("B is greater than A")
else:
print("B is not greater than A")

Output
B is not greater than A

and Example 

if A > B and C > A:
print("Both conditions are True")

Output
Both conditions are True

Or Example

if A > B or C > A:
print("Both conditions are True") 

Output
Both conditions are True

If Elif Else Statement in Python

How to Use If Else Statements

If, Else, and Elif Statements

error: Content is protected !!