Python 'if-else' Statement.
Learn about the basic syntax and usage of the 'if else' statement in Python, a conditional control flow tool used for decision making and controlling program flow. Optimize your coding skills with a clear understanding of how to use this fundamental programming concept.
1]if-else
a=13
b=200
# ***IF-ELSE***
if(a>b):
print("a is greater than b")
elif(a==b):
print("a is equal to b ")
else:
print("b is greater than a")
Output:-
b is greater than a
In ‘if-else’, we can add multiple conditions using ‘elif()’,
a=200
b=200
# ***IF-ELSE***
if(a>b):
print("a is greater than b")
elif(a==b):
print("a is equal to b ")
else:
print("b is greater than a")
Output:-
a is equal to
***COMMENTS DOWN, IF YOU HAVE ANY QUERIES***