← Debugging robot programs lesson New set →

Robotics Worksheet: Debugging Robot Programs

Robotics lesson 26: Debugging robot programs · Set 13 · 40 questions
TalentJR

Robot tip (Compare and fix one thing): Run it, spot what went wrong, find the buggy line, fix one thing, test again. Wrong side → a turn is the wrong way. Too far or too short → a forward number is wrong. A shape that does not close → the turn should be 360 ÷ sides; a gap → the repeat number should equal the sides.

NameDateTime takenScore ___ / 40
  1. 1.🐞 This program should draw a regular triangle (3 equal sides), but the shape does not close:
    repeat 3 { forward 10 cm; turn right 45° }
    What should 45 be changed to?
  2. 2.🐞 This program should draw a regular square (4 equal sides), but the shape does not close:
    repeat 4 { forward 10 cm; turn right 60° }
    What should 60 be changed to?
  3. 3.🐞 A robot starts at (5, 2) facing north (the second number counts squares up, the first counts squares across to the east). It should stop on the star at (3, 7). Its program:
    1. forward 5
    2. turn left
    3. forward 3
    It stops at (2, 7) instead. Which line has the bug?
    (a) line 2 (b) line 1 (c) line 3
  4. 4.🐞 Why change only one thing at a time when debugging? (a) to make it slower (b) to see what fixed it (c) to confuse others (d) to save paper
  5. 5.🐞 A mistake in a program is called a … (a) sensor (b) gear (c) bug (d) loop
  6. 6.🐞 This program should draw a regular triangle (3 equal sides), but it leaves a gap:
    repeat 2 { forward 10 cm; turn right 120° }
    What should the number 2 after “repeat” be?
  7. 7.🐞 This program should draw a regular pentagon (5 equal sides), but the shape does not close:
    repeat 5 { forward 10 cm; turn right 90° }
    What should 90 be changed to?
  8. 8.🐞 This program should draw a regular hexagon (6 equal sides), but the shape does not close:
    repeat 6 { forward 10 cm; turn right 120° }
    What should 120 be changed to?
  9. 9.🐞 A robot starts at (4, 2) facing north (the second number counts squares up, the first counts squares across to the east). It should stop on the star at (5, 5). Its program:
    1. forward 3
    2. turn left
    3. forward 1
    It stops at (3, 5) instead. Which line has the bug?
    (a) line 1 (b) line 3 (c) line 2
  10. 10.🐞 This program should draw a regular square (4 equal sides), but it leaves a gap:
    repeat 2 { forward 10 cm; turn right 90° }
    What should the number 2 after “repeat” be?
  11. 11.🐞 A robot starts at (4, 1) facing north (the second number counts squares up, the first counts squares across to the east). It should stop on the star at (3, 3). Its program:
    1. forward 2
    2. turn right
    3. forward 1
    It stops at (5, 3) instead. Which line has the bug?
    (a) line 3 (b) line 1 (c) line 2
  12. 12.🐞 A robot starts at (4, 2) facing north (the second number counts squares up, the first counts squares across to the east). It should stop on the star at (6, 8). Its program:
    1. forward 6
    2. turn left
    3. forward 2
    It stops at (2, 8) instead. Which line has the bug?
    (a) line 3 (b) line 1 (c) line 2
  13. 13.🐞 This program should draw a regular hexagon (6 equal sides), but the shape does not close:
    repeat 6 { forward 10 cm; turn right 72° }
    What should 72 be changed to?
  14. 14.🐞 This program should draw a regular octagon (8 equal sides), but the shape does not close:
    repeat 8 { forward 10 cm; turn right 120° }
    What should 120 be changed to?
  15. 15.🐞 This program should draw a regular square (4 equal sides), but the shape does not close:
    repeat 4 { forward 10 cm; turn right 72° }
    What should 72 be changed to?
  16. 16.🐞 This program should draw a regular triangle (3 equal sides), but the shape does not close:
    repeat 3 { forward 10 cm; turn right 72° }
    What should 72 be changed to?
  17. 17.🔢 To debug a robot program, which comes first: “test it again” or “find the buggy line”? (a) find the buggy line (b) test it again
  18. 18.🔢 To debug a robot program, which comes first: “test it again” or “spot what went wrong”? (a) test it again (b) spot what went wrong
  19. 19.🔢 To debug a robot program, which comes first: “run the program” or “find the buggy line”? (a) run the program (b) find the buggy line
  20. 20.🐞 This program should draw a regular square (4 equal sides), but the shape does not close:
    repeat 4 { forward 10 cm; turn right 120° }
    What should 120 be changed to?
  21. 21.🐞 A robot starts at (4, 0) facing north (the second number counts squares up, the first counts squares across to the east). It should stop on the star at (3, 4). Its program:
    1. forward 4
    2. turn left
    3. forward 2
    It stops at (2, 4) instead. Which line has the bug?
    (a) line 1 (b) line 2 (c) line 3
  22. 22.🐞 A robot starts at (4, 0) facing north (the second number counts squares up, the first counts squares across to the east). It should stop on the star at (2, 6). Its program:
    1. forward 6
    2. turn right
    3. forward 2
    It stops at (6, 6) instead. Which line has the bug?
    (a) line 3 (b) line 1 (c) line 2
  23. 23.🐞 A robot starts at (5, 0) facing north (the second number counts squares up, the first counts squares across to the east). It should stop on the star at (6, 2). Its program:
    1. forward 2
    2. turn right
    3. forward 2
    It stops at (7, 2) instead. Which line has the bug?
    (a) line 1 (b) line 3 (c) line 2
  24. 24.🐞 This program should draw a regular octagon (8 equal sides), but the shape does not close:
    repeat 8 { forward 10 cm; turn right 60° }
    What should 60 be changed to?
  25. 25.🐞 A robot starts at (4, 1) facing north (the second number counts squares up, the first counts squares across to the east). It should stop on the star at (7, 5). Its program:
    1. forward 3
    2. turn right
    3. forward 3
    It stops at (7, 4) instead. Which line has the bug?
    (a) line 1 (b) line 3 (c) line 2
  26. 26.🐞 This program should draw a regular hexagon (6 equal sides), but the shape does not close:
    repeat 6 { forward 10 cm; turn right 45° }
    What should 45 be changed to?
  27. 27.🐞 This program should draw a regular hexagon (6 equal sides), but it leaves a gap:
    repeat 3 { forward 10 cm; turn right 60° }
    What should the number 3 after “repeat” be?
  28. 28.🔢 To debug a robot program, which is the LAST step? (a) test it again (b) run the program (c) spot what went wrong (d) fix one thing
  29. 29.🐞 This program should draw a regular octagon (8 equal sides), but it leaves a gap:
    repeat 3 { forward 10 cm; turn right 45° }
    What should the number 3 after “repeat” be?
  30. 30.🐞 A robot turns the wrong way at every corner. What is the likely bug? (a) the floor is clean (b) battery is too new (c) wheels are too round (d) left and right mixed up
  31. 31.🔢 To debug a robot program, what comes right after “run the program”? (a) find the buggy line (b) test it again (c) fix one thing (d) spot what went wrong
  32. 32.🐞 A robot starts at (4, 2) facing north (the second number counts squares up, the first counts squares across to the east). It should stop on the star at (3, 5). Its program:
    1. forward 3
    2. turn right
    3. forward 1
    It stops at (5, 5) instead. Which line has the bug?
    (a) line 3 (b) line 2 (c) line 1
  33. 33.🐞 This program should draw a regular square (4 equal sides), but it leaves a gap:
    repeat 3 { forward 10 cm; turn right 90° }
    What should the number 3 after “repeat” be?
  34. 34.🔢 To debug a robot program, which comes first: “spot what went wrong” or “find the buggy line”? (a) spot what went wrong (b) find the buggy line
  35. 35.🔢 To debug a robot program, which comes first: “test it again” or “run the program”? (a) run the program (b) test it again
  36. 36.🔢 To debug a robot program, what comes right after “spot what went wrong”? (a) run the program (b) fix one thing (c) test it again (d) find the buggy line
  37. 37.🐞 A robot starts at (4, 0) facing north (the second number counts squares up, the first counts squares across to the east). It should stop on the star at (1, 2). Its program:
    1. forward 3
    2. turn left
    3. forward 3
    It stops at (1, 3) instead. Which line has the bug?
    (a) line 3 (b) line 1 (c) line 2
  38. 38.🐞 This program should draw a regular pentagon (5 equal sides), but it leaves a gap:
    repeat 3 { forward 10 cm; turn right 72° }
    What should the number 3 after “repeat” be?
  39. 39.🔢 To debug a robot program, which is the FIRST step? (a) fix one thing (b) find the buggy line (c) test it again (d) run the program
  40. 40.🔢 To debug a robot program, which comes first: “find the buggy line” or “fix one thing”? (a) fix one thing (b) find the buggy line

Answer key

  1. 120
  2. 90
  3. line 3
  4. to see what fixed it
  5. bug
  6. 3
  7. 72
  8. 60
  9. line 2
  10. 4
  11. line 2
  12. line 2
  13. 60
  14. 45
  15. 90
  16. 120
  17. find the buggy line
  18. spot what went wrong
  19. run the program
  20. 90
  21. line 3
  22. line 2
  23. line 3
  24. 45
  25. line 1
  26. 60
  27. 6
  28. test it again
  29. 8
  30. left and right mixed up
  31. spot what went wrong
  32. line 2
  33. 4
  34. spot what went wrong
  35. run the program
  36. find the buggy line
  37. line 1
  38. 5
  39. run the program
  40. find the buggy line

Free robotics lessons, practice and worksheets at talentjr.in/robotics-for-kids