Learning objective
Explain code and logic, reproduce the worked example and justify a decision in the case study.
Before you begin
Problem, requirements, and design
Understand
Variables, conditions, loops, and functions represent decisions and repetition.
Worked example
A condition can show different feedback depending on whether an answer is correct.
Analysis and common mistakes
A function transforms inputs into an output under a defined contract. Input validation distinguishes numbers, text and missing values. Side effects such as saving should be identifiable.
Case study — reasoning
A price × quantity function should reject negative quantities if returns are unsupported. Test zero, a valid quantity and non-numeric text; do not silently convert an error to zero.
Knowledge check
Summary
Variables, conditions, loops, and functions represent decisions and repetition.
Sources for further study and verification
AI-assisted draft · Educator review not completed · Unofficial supplementary resource