# KS2 Debugging – Beginners’ Activities

“Yay! Software that’s not terrifying!” Said every teacher born before 1985.

This simple online game is a quick and easy way to introduce very basic concepts relating to programming, in particular they focus on the function of algorithms. The way the activities are structured and the suggested discussions with learners are important. Use the time to reinforce vocabulary and to get pupils talking about programming. Extra time spent preparing and consolidating in the initial stages of coding/programming will pay dividends later on!

For an absolute beginner’s introduction to algorithms, click here.

Here we provide four differentiated activities that could be taught individually or in series depending on the age and ability of learners. Chop, change, mash or shape them to suit your and your class’ needs!

TOOLS

Practical Activity 1

Aim – to begin to understand the relationship between action and command in programming.

Introduce Etch-a-Sketch to the group on an interactive whiteboard. Explain to them that Etch-a-Sketch only understands commands given by the 4 arrow function keys. You may want to discuss that this is the ‘language’ used to tell Etch-a-sketch what you want it to ‘do’. Do NOT show them the different functions of the 4 keys.

Invite individuals up to the board to experiment with the game. Afterwards, ask them what they discovered – how many possibilities are there? What are the possibilities e.g. up, down, left, right, 4 diagonals and curved lines. Encourage them to explain to the class using full sentences and the correct terminology e.g. “If you want the cursor to move up 5 ‘steps’ you have to press the button 5 times”.  Point out that Etch-a-Sketch does exactly what you command; it NEVER moves more steps than you tell it to nor does it move in a direction that’s different to what you’ve commanded. This is true of ALL computer programs – they only do what they’ve been told or programmed to do.

Practical Activity 2

Aim – Begin to understand what an algorithm is and the importance of unambiguous commands in programming.

Discuss ways in which they could explain to a new user how to use Etch-a-Sketch. How could they explain to someone without long-winded text instructions? In pairs or groups, ask them to jot down ideas on paper or wipe-clean whiteboards. In the unlikely event that no one comes up with the idea, explain to them what a key is, you may want to show various examples e.g. a map key. Explain that the key is the basics of the language that both humans and Etch-a-Sketch will understand. Ask them to create a simple key that will explain to a new user how to use Etch-a-Sketch. On the left you will find 2 examples:

Explain that they have, in effect, created algorithms. Explain that an algorithm is a set of simple instructions for performing a task. Algorithms allow us to ‘talk’ or communicate with Etch-a-Sketch!

Practical Activity 3

Aim – Begin to understand the relationship between algorithms and programs and the importance of unambiguous commands in programming.

Ask the students what an algorithm is. Ask them what a computer program is. Ask them if they know what is the relationship between the two. Explain that they will be writing a simple computer program. Explain that a friend will test their computer program on Etch-a-Sketch. Using their key from the previous activity, they should write a series of algorithms that will ‘tell’ Etch-a-Sketch to draw a square. Their programs may look something like this:

^20, >20, v20, <20

OR

^ x 20, > x 20, ∨ x 20, < x 20

In pairs, ask them to test each other’s program. Remind them that Etch-a-Sketch ONLY does what it is told to do so, if they have not created a square there must be a fault (or bug) in their program OR they have made a mistake whilst inputting the commands! When each program has been tested, ask for feedback from the class. Discuss if their programs were easy or difficult to follow. Ask if anyone found any bugs!

Practical Activity 4

Aim – Begin to understand what a bug is, how to identify a bug and how to debug a simple program

Now that they know what a simple program might look like, show them examples that have mistakes (bugs) in the code. E.g.

^20, >20, ^20, <20

OR

^20, >20, v20, <10

In pairs, ask them to identify the bug in the code. If it helps, allow them to use Etch-a-Sketch to test the faulty programs. When they’ve identified the bug ask them to rewrite the algorithm correctly. If some finish the task quickly, ask them to write their own faulty program before giving it to a friend to ‘debug’ it.

Moving on:

• If you feel your pupils are ready to move on, click HERE for the first in a slightly harder series of programming activities. (All ages)
• If your pupils flew through these activities, you may like to click HERE for Python! (KS2)