Anatomy of Conditionals
Conditional statements let code make decisions. Click each highlighted part of this `if`/`elif`/`else` block to learn its role.
score = 75
if score >= 90:
print("Grade: A")
elif score >= 80:
print("Grade: B")
else:
print("Grade: C or lower")
Identify all parts!
Conditional Logic Builder
Drag pieces into the dark area to build an `if`/`elif`/`else` structure that assigns grades: A (>= 90), B (>= 80), C (< 80). Use the `score` variable.
Scenario Simulator
Write Python code using `if`, `elif`, and `else` to give clothing advice based on temperature.
Assume `temp` is already defined (we'll test with different values).
Trace the Execution
Given the input value, click ONLY the line(s) of code below that will actually execute. Click again to deselect. Then check your trace.
Mini Missions!
Apply your `if`/`elif`/`else` skills! Complete these coding tasks. Assume input variables (`age`, `num`) are provided.
Mission 1: Ticket Pricing
Given `age`, print the ticket price: "Child: $5" (age < 13), "Senior: $7" (age >= 65), "Adult: $10" (otherwise).
Mission 2: Number Check
Given `num`, print: "Positive" (num > 0), "Negative" (num < 0), "Zero" (num == 0).
Mission 3: Simple Login Check
Given `username`, print: "Admin Access" (if username is "admin"), "Guest Access" (if username is "guest"), "Unknown User" (otherwise).
Module 8 Practice Complete!
Excellent work navigating multiple conditions with `elif`! You're building complex logic.
Ready for more challenges? Try the Advanced Practice for Module 8!