☞ It allows you to check multiple conditions and execute different blocks of code accordingly.
☞ It's used when you have more than two possible outcomes.
Syntax :
if <test_condition>:
Statement_1
Statement_2
……….
elif <test_condition>:
Statement_1
Statement_2
……….
elif <test_condition>:
Statement_1
Statement_2
……….
else:
Statement_1
Statement_2
……….
score = int(input("Enter a score : "))
if score >= 90:
print("Grade: A")
elif score >= 80:
print("Grade: B")
elif score >= 70:
print("Grade: C")
elif score >= 60:
print("Grade: D")
else:
print("Grade: F")
Enter a score : 75 Grade: C