Choose exam board for KS4 Computer Science (GCSE)
Choose exam board for KS4 English
Choose exam board for KS4 French
Choose exam board for KS4 Geography
Choose exam board for KS4 German
Choose exam board for KS4 History
Choose tier for KS4 Maths
Choose exam board for KS4 Music
Choose exam board for KS4 Physical education (GCSE)
Choose exam board for KS4 Religious education (GCSE)
Choose exam board for KS4 Spanish

      Using selection to control the flow of a program

      Lesson details

      Learning outcome

      I can use a loop to repeatedly check whether a condition has been met.

      Key learning points

      1. Coding projects can have conditions and actions.
      2. A condition being met can be used to start an action.
      3. Selection can be used to control the flow of a program.

      Keywords

      • Condition - a statement that can be either True or False

      • Selection - part of a program where if a condition is met, then a set of commands is run

      Common misconception

      If… then… statements can be checked once in a program.

      An if... then... statement can be made to repeatedly check a condition by using a forever loop.

      Teacher tip

      Use live demonstrations of the Crumble programming software to support understanding and encourage pupil questions about selection and control.

      Equipment

      Pupils will need access to a microcontroller, crocodile clips, battery packs, Sparkle LEDs and push button switches. Examples in this lesson use Crumble https://oak.link/crumble

      Licence

      This content is © Oak National Academy Limited (2026), licensed on Open Government Licence version 3.0
      except where otherwise stated. See Oak's terms & conditions
      (Collection 2).

      Lesson video

      Loading...

      Prior knowledge starter quiz

      6 Questions

      Q1.
      What is a condition in programming?

      Correct answer: a statement that can be True or False
      a set of instructions
      a loop that repeats code
      a type of error in the program

      Q2.
      What does a conditional loop do?

      stops the program
      Correct answer: repeats code until a condition is met
      jumps to another part of the program
      runs code only once

      Q3.
      Which of these is an example of a condition?

      the program runs
      the microcontroller turns on
      a loop stops repeating
      Correct answer: if the button is pressed

      Q4.
      What is the purpose of a microcontroller?

      to display images
      to store large amounts of data
      Correct answer: to respond to inputs
      to connect to the internet

      Q5.
      What does True mean in programming?

      a loop is running
      a program has stopped
      Correct answer: a condition is met
      an error has occurred

      Q6.
      Put these steps in order to program a microcontroller.

      1 - write the program
      2 - upload the program to the microcontroller
      3 - run the program

      6 Questions

      Q1.
      Match the terms to their examples.

      Correct Answer:condition,If the button is pressed, ...

      If the button is pressed, ...

      Correct Answer:selection,If the temperature is below 20°C, turn on the heater.

      If the temperature is below 20°C, turn on the heater.

      Correct Answer:True,The light is on.

      The light is on.

      Correct Answer:False,The button is not pressed.

      The button is not pressed.

      Q2.
      What type of loop repeatedly checks a condition?

      Correct Answer: forever, forever loop

      Q3.
      What is a condition in programming?

      Correct answer: a statement that can be True or False
      a set of commands
      a loop that repeats code
      a type of error in the program

      Q4.
      What is selection in programming?

      a loop that repeats code
      a method for storing data
      Correct answer: a way to control program flow based on conditions
      a tool to refine search terms

      Q5.
      What is the purpose of an if… then… statement?

      to repeat code
      to store data
      Correct answer: to check a condition and run commands if the condition is met
      to create a loop

      Q6.
      Selection allows a program to make decisions by checking a .

      Correct Answer: condition

      To help you plan your 5 computing lesson on: Using selection to control the flow of a program, download all teaching resources for free and adapt to suit your pupils' needs...