Finding and Fixing Bugs in Instructions

Finding and Fixing Bugs in Instructions

1 / 34
next
Slide 1: Slide
New lesson editorComputingPrimary Education

This lesson contains 34 slides, with interactive quizzes and text slides.

time-iconLesson duration is: 50 min
Report this lesson

Items in this lesson

Finding and Fixing Bugs in Instructions

Open with the idea that computers follow instructions exactly, so even a small mistake can cause the wrong result. Keep examples concrete and familiar.

Our learning goal

I can find a bug in instructions and fix it so the algorithm works.

This item has no instructions

What words make you think of finding a bug?

Use this to surface prior ideas such as mistake, wrong, fix, check, code, robot or instructions. Accept everyday language and link it to the lesson vocabulary.

Lesson introduction

This KS1 computing lesson explores Finding and Fixing Bugs in Instructions. Pupils identify errors in simple algorithms and programs, explain why they cause an incorrect result and make changes to fix them. It is suitable for classroom teaching, independent practice or a clear recap of the topic.

This item has no instructions

What we already know

  • An algorithm is a set of instructions.

  • Instructions need to be in the right order.

  • Computers do exactly what they are told.

  • If the instructions are wrong, the result can be wrong too.

Use this as prior knowledge. Link to earlier work on algorithms, sequencing and giving simple instructions to people or devices.

What is a bug?

A bug is a mistake in instructions or in a program.


A bug can make something stop, do the wrong thing or happen in the wrong order.

Keep the definition simple. For KS1, focus on wrong order, missing step and wrong instruction rather than technical coding errors.

A bug in everyday instructions

  • Put cereal in the bowl

  • Eat the cereal

  • Pour in the milk


The instructions are not quite right. The order has a bug.

Read the steps aloud dramatically so pupils notice the silly result. This helps them understand debugging before moving to computers.

What is debugging?

Debugging means finding a bug and fixing it.


We look carefully at the instructions, spot the mistake and change it so it works.

This item has no instructions

What does debugging mean?

A

Finding and fixing

B

Starting a game

C

Drawing a robot

D

Pressing stop

Checks the core definition from slides 4 to 6.

Complete the idea

A bug is a mistake in instructions. Debugging means finding the bug and fixing it so it works.

bug
Debugging
fixing
drawing
running
jumping
button

Reinforces the key vocabulary pupils need before moving on.

How to debug

  • Read each step carefully

  • Check the order

  • Find the bug

  • Fix the step

  • Try the instructions again

Model this routine repeatedly across the lesson so pupils have a simple process to follow.

When instructions go wrong

A bug can happen when:

  • a step is in the wrong order

  • a step is missing

  • the instruction says the wrong action

These three bug types are enough for this age group and align well with simple algorithms and programs in the English national curriculum.

Bug type: wrong order

If steps are mixed up, the algorithm may not work.


First → Next → Last must make sense.

Point back to sequencing knowledge. This is the most familiar entry point for KS1 pupils.

Bug type: missing step

Sometimes a step is left out.


If one important step is missing, the whole set of instructions may fail.

Give a spoken example such as 'brush teeth' without 'put toothpaste on the brush'.

Bug type: wrong instruction

A step can tell the wrong action.


For example, turn left instead of turn right.

This prepares pupils for simple programmed movement and direction-based debugging.

Which one is a missing step bug?

A

Turn left, not right

B

Brush teeth, no toothpaste

C

Eat, then pour milk

D

Go back to start

The correct option matches the taught example of a left-out important step. The other answers reflect wrong instruction or wrong order ideas.

Finish the bug types

A bug can happen when a step is in the wrong order. A step might be missing. The instruction might say the wrong action.

wrong order
missing
wrong action
right order
extra
same action
quickly

All three blanks come directly from slide 8 and the bug-type slides.

Reading an algorithm carefully

Good debugging starts with careful reading.


Check one step at a time. Do not guess. Look for the exact place where the instructions stop making sense.

Emphasise that debugging is a careful thinking job, not just trying random changes.

Example: moving a robot

  • Forward

  • Forward

  • Turn left

  • Forward


If the robot reaches the wrong square, one step may be a bug.

You can mime the path or trace it in the air. Pupils should see that the wrong result tells us there is a bug somewhere.

Find the bug by checking each step

Read the algorithm slowly:


Forward → Forward → Turn left → Forward


Ask: does each step help the robot get to the right place?

This is a useful place to pause and model line-by-line checking. Keep language simple and visual.

Fix the bug

If Turn left is wrong, we change it.


Forward → Forward → Turn right → Forward


Now the algorithm has been debugged.

Make explicit that debugging means changing only what needs fixing, then checking again.

Which step fixed the robot algorithm?

A

Turn right

B

Turn left

C

Go backwards

D

Stop here

Checks whether pupils noticed that only one step needed changing in the robot example.

How would you check the robot steps?

Look for answers that mention checking each step slowly, spotting the wrong step, or changing only the bug. Accept simple phrases in pupils' own words.

Programs can have bugs too

A program is an algorithm made for a computer.


If the program has a bug, the computer still follows it exactly.

Keep the distinction light: algorithm = instructions; program = instructions for a computer.

Why the wrong result matters

The wrong result is a clue.


It tells us the instructions need checking. We use what happened to help us find the bug.

Encourage pupils to see mistakes as helpful information, not failure.

Try, check, fix

Program runs → wrong result → find the bug → fix the code → run it again


This is how programmers improve their work.

Use the arrow chain here because the process itself is the teaching point.

Application activity

Look at a short set of instructions or a simple program.


Find the bug, say what is wrong and change it so it works correctly.

Teacher can provide differentiated examples: easier tasks with one obvious sequencing bug; harder tasks with a missing or incorrect direction step.

Different ways to succeed

Support

  • Find more than one bug

  • Explain why it is wrong

  • Write the corrected algorithm

  • Debug a longer sequence

  • Use picture cards

  • Read steps aloud together

  • Fix one step only

  • Follow the instructions physically

Challenge

This captures differentiation the teacher requested while staying pupil-friendly on the slide.

What good debuggers do

  • Look carefully

  • Check each step

  • Notice the wrong result

  • Make a sensible change

  • Test again

Use this as a brief summary before the glossary.

If a program has a bug, what does the computer do?

A

It fixes itself

B

It asks for help

C

It follows it exactly

D

It misses a turn

Checks the important idea from slides 16 to 18 that computers follow instructions exactly, even when they are wrong.

What helps you debug best?

1

Read slowly

2

Check order

3

Fix one step

4

Try again

This item has no instructions

What is one thing you learned today?

Reflection only. Encourage simple responses such as bug types, checking steps, or changing the wrong instruction.

What felt hardest in this lesson?

Reflection only. Pupils might mention missing steps, right and left directions, or putting steps in order.

Glossary

algorithm - a set of instructions

bug - a mistake in instructions or a program

debugging - finding and fixing a bug

program - an algorithm made for a computer

sequence - the order of the steps

step - one instruction in an algorithm

result - what happens at the end

This item has no instructions