number = -5
if number > 0:
print('Positive number')
elif number < 0:
print('Negative number')
else:
print('Zero')
print('This statement is always executed')Negative number
This statement is always executed
elif statementif/elif/else statements using correct syntax, indentation and conditions.elif statementThe if...else statement is used to execute a block of code among two alternatives.
However, if we need to make a choice between more than two alternatives, we use the if...elif...else statement.
The elif keyword is short for “else if” and is used to check multiple conditions, stopping as soon as it finds the first true condition.
if/elif/else
If the condition1 inside the if statement evaluates to
True - the body of the if executes, and the body of the elif and the else are skipped (without checking condition2)
False - the body of the if is skipped, then the condition2 is checked. If evaluates to
True, the body of the elif is executed while the body of the else is skipped
False, the body of the else is executed instead.

The way to assemble subsequent if-elif-else statements is sometimes called a cascade.
Some additional attention has to be paid in this case:
This may sound a little puzzling, but hopefully some simple examples will help shed more light.
Consider the following code:
Negative number
This statement is always executed
Here, the first condition, number > 0, evaluates to False. In this scenario, the second condition is checked.
The second condition, number < 0, evaluates to True. Therefore, the statements inside the elif block is executed.
In the above program, it is important to note that regardless the value of number variable, only one block of code will be executed.
🎯 Test Myself: Write a Python program that asks the user to input a temperature in Celsius and then checks if the temperature is below freezing, above boiling, or in between.
🎯 Test Myself: Write a Python program that assigns a letter grade based on a numeric score. Ask the user to input a score, then determine and print the letter grade: