A simple Python program that shows the functionality of an if-else
statement.
num = -5
if num < 0:
print("number is negative")
elif num == 0:
print("0")
else:
print("number is positiv")
number is negative
The code checks the value of the variable num
and prints the appropriate message based on its value. If num
is less than 0, the message “number is negative” will be printed. If num
is equal to 0, the message “0” will be printed. If num
is greater than 0, the message “number is positive” will be printed.