0% found this document useful (0 votes)
9 views

AP Worksheet – Debugging

Uploaded by

22pereirag
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

AP Worksheet – Debugging

Uploaded by

22pereirag
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Year 7 – Programming essentials in Scratch: part I Learner activity sheet

Lesson 5 – Count-controlled iteration

Debugging
The program below asks the user which times table they would like to know. The Scratch
cat program should then say the times table for them. Unfortunately, this program
doesn’t output the correct data.

Run the program for yourself.

The program can be found here: times table program (ncce.io/TimesTableDebugging)

Questions Your answers ▿

● Describe what happens


when you run the
program.

Page 1 Last updated: 08/03/2021


Year 7 – Programming essentials in Scratch: part I Learner activity sheet
Lesson 5 – Count-controlled iteration

One technique you can use to help you debug code is to add lines of code that show the
variables that may play a part in the bug.

Add two lines of code that ‘say’ the value of your variables each time the program
iterates. It should now look like the following:

For this exercise, assume that when asked ‘What times table would you like?’ a number
‘2’ was entered. Note the values of the two variables and the final output just for the first
four iterations.

Iteration Value of: Value of Output

Page 2 Last updated: 08/03/2021


Year 7 – Programming essentials in Scratch: part I Learner activity sheet
Lesson 5 – Count-controlled iteration

Program code here to test out the theory.

Questions Your answers ▿

● What did you discover was


the bug/error with the
program?

● Can you recommend a


way of fixing this bug?

Explorer tasks

1. Remove the two print lines from the code


2. Fix the bug so that you have a working program

Resources are updated regularly — the latest version is available at: ncce.io/tcc.

This resource is licensed under the Open Government Licence, version 3. For more information on this
licence, see ncce.io/ogl.

Page 3 Last updated: 08/03/2021

You might also like