2.4.1.2 if-else Statement
Python Programming
The if-else statement allows us to execute one block of code if a condition is true and another block if the condition is false.
python
# Syntax of if-else statement if condition:
if condition:
# code to run if the condition is true else :
else:
# code to run if the condition is falseExample
python
temperature = 15
if temperature > 30:
print("It’s a hot day ")
else :
print("It’s not a hot day "