Python Learning Series · @onlysamarrr · Day 8 / 30
Day 8 teaches if-else decisions. If the condition is True the if block runs, otherwise the else block runs. Blocks are recognised by 4-space indentation.
Phase: Beginner · Reels: 36/450 – 40/450
Day 8 teaches if-else decisions. If the condition is True the if block runs, otherwise the else block runs. Blocks are recognised by 4-space indentation.
marks = 72
if marks >= 90:
grade = "A"
elif marks >= 60:
grade = "B"
else:
grade = "C"
print(grade)
status = "Pass" if marks >= 33 else "Fail"
print(status)
B Pass
Pass/fail results, login checks and discount rules are all if-else logic.
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 = 20. What does "Pass" if marks >= 33 else "Fail" give?
Q2. What causes an IndentationError?
Q3. In an elif chain, how many blocks run?
| 36/450 | Concept | if-else ka logic |
| 37/450 | Live demo | Pass ya fail program |
| 38/450 | Common mistake | Indentation error |
| 39/450 | Quiz | Quiz: bada number batao |
| 40/450 | Interview / real life | Real life: login check |