What you will learn
  • 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 and when every condition must be true.
  • Use or when any allowed condition is enough.
Input → condition? ─True→ action A
                  └False→ action B

A 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.

Python
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

  1. Choose a valid range from 0 through 100.
  2. Write an if/else check.
  3. Test -1, 0, 100, and 101.
  4. Record which branch each value takes.
  5. 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

  1. What is the main purpose of conditional decisions?

  2. What does “Boolean” mean in this lesson?

  3. How is “Condition” used?

  4. Why should you test one boundary or subsystem at a time?

  5. What should the system do when an input is missing or invalid?

  6. In your own words, what does “Boolean” mean?

  7. In your own words, what does “Condition” mean?

  8. In your own words, what does “Comparison operator” mean?

  9. In your own words, what does “Branch” mean?

  10. In your own words, what does “Boundary” mean?

Quiz answers

Reveal all 10 answers after your attempt
  1. 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.
  2. A value that is either True or False.
  3. An expression tested by a decision statement.
  4. It reveals where the expected value or behavior first changes, so debugging is based on evidence.
  5. It should reject the input, report the problem, or move to a documented safe state instead of guessing.
  6. A value that is either True or False.
  7. An expression tested by a decision statement.
  8. An operator such as <, ==, or >=.
  9. One possible path through conditional code.
  10. 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 path

Sources 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.