Conditionals: Worked Reasoning

30 min
0/5 practice checks

Worked Reasoning

Make each reasoning step visible: identify the knowns, choose the governing idea, apply it and check the result.

This extension applies that lens specifically to Conditionals.

Conditionals run code only when a condition is true:

if age >= 18:
    print("adult")
elif age >= 13:
    print("teen")
else:
    print("child")

The comparison operators produce a bool: == equal, != not equal, <, >, <=, >=. Indentation (4 spaces) is how Python knows which lines belong inside the if.

Code practice

Python Foundations — Worked Reasoning: Write classify(n) that returns "positive" if n is greater than 0, "negative" if less than 0, and "zero" otherwise.

python

Runs in your browser. Charts (matplotlib) are not supported — use print-based output.

Code practice

Python Foundations — Worked Reasoning: For the given age = 20, set is_adult to a bool that is True when age is at least 18.

python

Runs in your browser. Charts (matplotlib) are not supported — use print-based output.

Python Foundations — Worked Reasoning: What does the expression 7 != 3 evaluate to?

Name the original topic being extended by this worked reasoning lesson.

Which statement is the best evidence-led starting point for Conditionals: Worked Reasoning?