AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Spot the bug

Week 9 · Unit 1 · 1.4 · 3 lessons
3

Fix it and run again

Computing 1: Topic 1.4, pp. 49–59
GoalFix a bug in code and run the program again to check it.
New words
fix · change the code so that it is righttest · run the code to see if it works
Explanation

First find the bug. Then change the card. Then run the code again. This is called testing. If the robot reaches the goal, the bug is fixed. If not, there may be another bug. Look again. Be patient!

findfixruntest
Worked examples
Code: F F R F F F ends one square below the star. The robot should go up three first. Fix: add an F at the start. New code: F F F R F F F.
Some programs have two bugs. Code: F L F F F. The robot should reach the tree. Fix: F F L F F. It needs two squares up and then two squares left, not one up and three left.
it works!
After a fix, always test. If the robot is still wrong, look for another bug. Keep trying until it works.
Class activity

Fix and test: use the code from the bug detective game. Fix your friend’s bug. Walk it on the floor grid. Did the toy reach the goal? If not, look for a second bug. Say what you changed.

Practice
1
The robot starts at the bottom left facing up. The flower is two squares up and two squares right. The code F F R F stops short. Fix it.
2
After you fix a bug, why do you run the code again?
3
You tested the fix and the robot is still wrong. What do you do?
4
Which button must be pressed to run the program?
clear??????