Python Learning Series · @onlysamarrr · Day 9 / 30
Day 9 covers elif chains and nested if. Use elif when conditions must be checked one after another, and prefer and over a nested if when two conditions must both be true.
Phase: Beginner · Reels: 41/450 – 45/450
Day 9 covers elif chains and nested if. Use elif when conditions must be checked one after another, and prefer and over a nested if when two conditions must both be true.
marks = 85
if marks >= 90:
print("A")
elif marks >= 75:
print("B")
elif marks >= 60:
print("C")
else:
print("Fail")
age = 20
has_id = True
if age > 18 and has_id:
print("Entry allowed")
else:
print("Entry denied")
B Entry allowed
Grade calculators, ticket pricing and access rules use elif chains in real apps.
Select (tick) an option, then tap Check answer to see instantly whether your answer is right or wrong, with an explanation. You can change your answer and check again.
Q1. marks = 85 with elif checks 90+, 75+, 60+. What prints?
Q2. Which year is a leap year?
Q3. What does age > 18 and has_id need?
| 41/450 | Concept | elif kab use karein |
| 42/450 | Live demo | Grade calculator demo |
| 43/450 | Common mistake | Multiple if vs elif |
| 44/450 | Quiz | Quiz: leap year |
| 45/450 | Interview / real life | Interview: nested if vs and |