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

      Writing and testing algorithms

      Lesson details

      Learning outcome

      I can create a physical project that includes selection.

      Key learning points

      1. An algorithm can describe what a physical model will do.
      2. Selection can be used to produce an intended outcome.
      3. Programs are improved through debugging.

      Keywords

      • Algorithm - a precise set of ordered steps which can be followed by a human or a computer to do a task

      • Repetition - part of a program where one or more commands are run multiple times in a loop

      • Debug - finding and fixing errors in a program

      Common misconception

      You should write all the code before testing.

      Test small parts frequently to catch errors early. It is easier to fix a few errors at a time than all of them at once.

      Teacher tip

      Consider linking this lesson with Design and Technology time, and encourage pupils to collaborate in pairs or small groups to manage the model-building and testing process effectively.

      Equipment

      Pupils will need model making materials, a microcontroller, crocodile clips, battery packs, Sparkle LEDs, push button switches and motors. 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 selection in programming?

      a loop that repeats commands indefinitely
      a way to store information
      Correct answer: a part of a program where if a condition is met, a set of commands is run
      a condition that always evaluates to True

      Q2.
      What is a condition in programming?

      Correct answer: a statement that can be True or False
      a loop that repeats commands
      a command that always runs
      a way to stop a program

      Q3.
      What does repetition mean in programming?

      Correct answer: running commands multiple times in a loop
      stopping the program when a condition is met
      storing information for future use
      running all commands in order once

      Q4.
      Is a Sparkle an input device, an output device or neither?

      Correct Answer: output, output device, an output device

      Q5.
      What is the process of finding and fixing errors in a program called?

      Correct Answer: debug, debugging

      Q6.
      Arrange the steps for creating a coding project:

      1 - create a detailed drawing or plan
      2 - write an algorithm for the project
      3 - translate the algorithm into code
      4 - test and debug the code

      6 Questions

      Q1.
      What is an algorithm?

      a loop that repeats commands indefinitely
      a condition that is always True
      a tool used to store data
      Correct answer: a precise sequence of steps to complete a task

      Q2.
      What does debugging mean?

      writing new code
      repeating commands in a loop
      Correct answer: finding and fixing errors in a program
      storing data in a program

      Q3.
      Why is it important to test small parts of code frequently?

      to make the program run faster
      to avoid writing algorithms
      Correct answer: to catch errors early and fix them
      to reduce the need for repetition

      Q4.
      Why is an algorithm important in programming?

      Correct answer: it helps plan the steps needed to complete a task
      it repeats commands in a loop
      it stores information in the program
      it stops the program from running

      Q5.
      Arrange the steps for debugging a program:

      1 - identify the error
      2 - find the part of the code causing the error
      3 - fix the error in the code
      4 - test the program to ensure the error is fixed

      Q6.
      Match the key words and definitions.

      Correct Answer:algorithm,a precise sequence of steps that can be followed to do a task

      a precise sequence of steps that can be followed to do a task

      Correct Answer:repetition,a program where one or more commands are run multiple times in a loop

      a program where one or more commands are run multiple times in a loop

      Correct Answer:debug,finding and fixing errors in a program

      finding and fixing errors in a program


      To help you plan your 5 computing lesson on: Writing and testing algorithms, download all teaching resources for free and adapt to suit your pupils' needs...