Debugging and light grids
Answers are for parents and teachers.
1
Write the five rows of code for the letter T on the 5 × 5 grid.
Row 1: 99999. Rows 2 to 5: 00900. With colons: "99999:" "00900:" "00900:" "00900:" "00900".
2
Look at this code. Draw the picture it makes, and count how many lights are on.
Python
1from microbit import * 2display.show(Image( 3 "00900:" 4 "09990:" 5 "99999:" 6 "09990:" 7 "00900"))
It makes a diamond: 1 + 3 + 5 + 3 + 1 = 13 lights are on.
3
Put the lines in the right order to show a heart for 1 second and then switch the lights off. Write the letters in order.
| Letter | Line |
|---|---|
| A | sleep(1000) |
| B | from microbit import * |
| C | display.show(Image.HEART) |
| D | display.clear() |
B, C, A, D. First the import line, then the heart, then the wait of 1000 milliseconds, then clear.
4
Plan a blinking lamp with two images of your own: draw its flowchart steps and the two grids as rows of 0 and 9. Check that every row has five digits.
Any plan with: display image 1, wait, display image 2, wait, clear screen, and two grids with five rows of five digits, is correct. Check each grid by counting digits.
5
Explain in two sentences why a delay such as sleep(500) is needed between two images.
Without a delay the second image replaces the first so quickly that the first cannot be seen. A delay of half a second (500 milliseconds) gives the eye time to see each image.