AP Worksheet – Debugging
AP Worksheet – Debugging
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.
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.
Explorer tasks
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.