Year 8 · Algorithms and programming · original lesson pack
DASKEREL beta · internal AI review pending
Use an if statement to select one path
Open this lesson's library recordOfficial curriculum or provision guidance
DASKEREL wrote this teaching and practice using Oak's sequence as a source. View the source lesson at Oak National Academy. Oak has not endorsed this material. Check Oak's terms and separate rights for third-party works.
- DfE Key Stage 3 computing programme
- Oak Year 8 introduction to Python source-sequence lesson
- Python 3 tutorial and language reference
Learning outcomes
- Explain a Boolean comparison controlling a branch
- Trace exactly one if/else path for a numeric value
Vocabulary: selection · condition · Boolean · comparison · if · else
Retrieve previous learning
Why convert a whole-number input before comparing it with 5?
Check: A numeric comparison needs a numeric value; input alone returns text.
Learn the concept
Selection lets a program choose an action after evaluating a condition. In the original fictional reading challenge shown in the code sample, points is already an integer. The if test points >= 5 chooses between Goal reached and Keep going. The comparison is Boolean: it is either True or False. With points = 5 it is True because >= includes equality; the first message prints. With points = 4 it is False, so the else message prints.
Python uses a colon after the if condition and indentation to show which statement belongs to each branch. The else line aligns with if. Only one of these two branch bodies runs in a single evaluation. A trace should show the tested value, the condition's Boolean result, the path chosen and the exact output. Do not treat the word else as another condition; it handles the remaining cases when the if test is False.
The comparison == asks whether values are equal, while = assigns a value. Replacing points >= 5 with points = 5 inside an if statement is invalid Python syntax. It is also a design error to tell pupils that a message proves reading mastery: the points are an invented score, and a real education decision would require validated evidence. This lesson assesses program tracing and reasoning, not a pupil's reading level.
points = 5
if points >= 5:
print('Goal reached')
else:
print('Keep going')At points 5, only Goal reached is displayed; setting points to 4 selects the else path.
Run Python in DASKEREL
Use this editor alongside “Use an if statement to select one path”. Write or change a program, predict its output, then run it. Standard-library Python runs in an isolated browser frame and disposable worker. Each run starts fresh.
Preparing isolated runner…
Output and errors
Run your program to see its output here.
Ready for a longer exercise? Download a DASKEREL notebook for Google Colab. Colab opens separately and does not receive this editor's code automatically.
The Python runtime is downloaded from the pinned Pyodide distribution on first use. Code runs only in this isolated browser frame, with no DASKEREL account access. Programs stop after five seconds; output is capped. This tool does not save code or install packages. Avoid personal or sensitive data.
Worked model
- Set points = 5 in the fictional model.
- Evaluate points >= 5 and record True.
- Follow the indented if body and predict Goal reached.
- Set points = 4 and repeat; record False and follow else.
- Check the colon and indentation in both branches.
Guided practice
With points = 5, which message appears, and why?
Hint: The comparison includes equality.
Check the guided answer
Goal reached appears, because 5 >= 5 evaluates to True. The else body is skipped for that run.
Independent practice
Write your own response to every question before viewing the model answers. Your writing stays in this page session; this activity does not submit, store or grade it. Avoid including private information.
Find and correct a misconception
“An if/else program runs both messages in order.”
Correction: The Boolean condition chooses one of the two branches for each evaluation.
Extend and reflect
Change the threshold to 10 and test the boundary.
Guidance: Use points 9, 10 and 11, recording the condition result and the printed message for each.
Where this lesson could lead · Computer Science GCSE → Daskerel Computing and AI
This lesson practises: Explain a Boolean comparison controlling a branch. Algorithms, digital systems and safe practice support later software and technology work.
- Next school subject: Computer Science GCSE. Check the subject and examination board that fit your school.
- Later DASKEREL learning: Daskerel Computing and AI. Explore further study and build evidence from practical work.
- Later credential exploration: AWS Certified Developer - Associate is an example in this later specialism. Check current awarding-body requirements before planning an exam.
- Example career direction: Software Engineer. Explore organisations and local support.
This is an exploratory route, not a promise of admission, a qualification, certification eligibility or employment. Years 7–9 learning is an early foundation; any later credential may require substantial study, experience or local approval.