Foundation lesson for decision-making in Python. Read theory first, then explore real-world branching.
if checks a yes/no. Only one branch runs.
Python tests from the top. The first true branch wins.
A conditional lets your program choose one path based on a condition. If the condition is true, one block runs; otherwise another runs.
Used in login success/failure, payment status, grade assignment, eligibility checks, and almost every app decision.
if / elif / else ends with :>, <, ==, != return True or False.if it is raining → take umbrella. else → leave it home. No umbrella logic runs on sunny days. Code works the same: only the matching branch executes.
Answer all questions, then click Check answers. Use this before Practice in the editor.
Q1. What does `if` control?
Q2. In if / elif / else, how many branches run?
Q3. What is `n > 0` when n is -3?
Q4. Leap year logic mainly checks divisibility by…