- Explain conditional decisions in plain language.
- Trace information from input to output.
- Test one subsystem independently.
- Recognize a common failure and respond safely.
- Modify the example without changing several variables at once.
The central idea: conditional decisions
A condition is an expression that evaluates to True or False. if, elif, and else select exactly which block runs, while Boolean operators combine smaller conditions.
Treat the system as a chain of observable inputs, explicit processing, a decision, and an output. That makes the design easier to explain and gives you a place to test when something fails. A working result is not enough: record what input produced it and what evidence shows the result is correct.
Follow the information through the system
Read the diagram from left to right. Each arrow is a boundary where data, electrical signals, or commands move between parts. Test those boundaries separately before combining the whole system.
A sensor-quality check accepts readings within a documented range and rejects values outside it instead of using them blindly.
- Write boundary values explicitly.
- Use
andwhen every condition must be true. - Use
orwhen any allowed condition is enough.
Input → condition? ─True→ action A
└False→ action BA small working example
Run this example exactly as shown before modifying it. Predict the output first, compare that prediction with the real result, and change only one part at a time.
reading = 72
if 0 <= reading <= 100:
print("Reading accepted")
else:
print("Reading rejected")The chained comparison verifies both the lower and upper boundary.
Expected result: Reading accepted
Test before you trust the result
Start with a normal case, then test a boundary case and a failure case. For software, try empty, unexpected, and extreme inputs. For hardware, begin with wheels raised or actuators disconnected, keep a physical power switch within reach, and verify safe stopping behavior.
Write down the expected result before each test. If the observation differs, stop and find the first boundary where the expected signal disappeared. This method is slower than changing many things at once, but it produces evidence instead of guesses.
- Test one input with a known value.
- Observe the intermediate value before the final action.
- Confirm a safe response when input is missing or invalid.
- Repeat the same test to check consistency.
Important terms
- Boolean
- A value that is either True or False.
- Condition
- An expression tested by a decision statement.
- Comparison operator
- An operator such as
<,==, or>=. - Branch
- One possible path through conditional code.
- Boundary
- An edge value where behavior changes.
Mini project: practice conditional decisions
- Choose a valid range from 0 through 100.
- Write an if/else check.
- Test -1, 0, 100, and 101.
- Record which branch each value takes.
- Add a message explaining rejected values.
Common mistakes and debugging
- Using
=instead of==for comparison. - Forgetting that indentation defines a block.
- Leaving gaps or overlaps at boundaries.
- Writing nested conditions when one clear expression is enough.
Independent challenge
Classify a battery percentage as critical below 15, low below 35, or normal otherwise. Test the two exact boundaries.
Check your understanding: 10 questions
What is the main purpose of conditional decisions?
What does “Boolean” mean in this lesson?
How is “Condition” used?
Why should you test one boundary or subsystem at a time?
What should the system do when an input is missing or invalid?
In your own words, what does “Boolean” mean?
In your own words, what does “Condition” mean?
In your own words, what does “Comparison operator” mean?
In your own words, what does “Branch” mean?
In your own words, what does “Boundary” mean?
Quiz answers
Reveal all 10 answers after your attempt
- A condition is an expression that evaluates to
TrueorFalse.if,elif, andelseselect exactly which block runs, while Boolean operators combine smaller conditions. - A value that is either True or False.
- An expression tested by a decision statement.
- It reveals where the expected value or behavior first changes, so debugging is based on evidence.
- It should reject the input, report the problem, or move to a documented safe state instead of guessing.
- A value that is either True or False.
- An expression tested by a decision statement.
- An operator such as
<,==, or>=. - One possible path through conditional code.
- An edge value where behavior changes.
Summary
conditional decisions becomes manageable when you identify the input, processing, decision, output, and evidence of success. Build the smallest version, test it, then make one measured change.
Continue learning
Continue to the next lesson, which builds on this model with one additional capability.
Choose a connected learning pathSources and further reading
Prepared 2026-10-02. Editorially completed for the course. Software examples are designed for current Python 3; verify board, operating-system, library, and hardware details against the linked primary documentation before a physical build.