1. Lessons Cloze Review
1.1. Question 1
Complete the code to import the micro:bit library and scroll a simple text message.
Word Bank (Drag items below):
include
import
show
scroll
from microbit Drop here *
while True:
display.Drop here("Hello")
1.2. Question 2
Complete the statement to check if the A-button is being pressed down at this exact split-second.
Word Bank (Drag items below):
was_pressed
has_pressed
is_pressed
from microbit import *
while True:
if button_a.Drop here():
display.show("A")
1.3. Question 3
Fill in the missing syntax to loop through every character in a secret word text variable.
Word Bank (Drag items below):
of
in
range
show
write
from microbit import *
passcode = "ZEBRA"
for letter Drop here passcode:
display.Drop here(letter)
sleep(300)
1.4. Question 4
Complete the program to flash the numbers 0, 1, and 2 onto the screen using the range() function and a custom delay of 400 milliseconds.
Word Bank (Drag items below):
2
1
400
"400"
3
delay=400
from microbit import *
for count in range(Drop here):
display.show(count)
sleep(Drop here)
1.5. Question 5
Finish this selection structure so that it falls back to a default “catch-all” action if no buttons are down.
Word Bank (Drag items below):
else
default
if
else if
elif
finish
if button_a.is_pressed():
display.show("A")
Drop here button_b.is_pressed():
display.show("B")
Drop here:
display.clear()
1.6. Question 6
Complete this data-tracking script to safely check if a click happened in the past and automatically reset the log.
Word Bank (Drag items below):
sleep
is_pressed
pause
was_pressed
cleared
wait
from microbit import *
while True:
if button_b.Drop here():
display.show(Image.HAPPY)
Drop here(100)
1.7. Question 7
Complete the parameters to scroll a numeric variable with a fast custom delay speed of 50 milliseconds.
Word Bank (Drag items below):
delay=500
"50"
50
from microbit import *
score = 950
while True:
display.scroll("SCORE=", Drop here)
display.scroll(score)
1.8. Question 8
Finish the loop punctuation and matching variable setup to scroll text elements step-by-step.
Word Bank (Drag items below):
levels
;
:
status
from microbit import *
levels = ["LOW", "HIGH"]
for status in levelsDrop here
display.scroll(Drop here)
1.9. Question 9
Complete the program to flash a word character-by-character with a faster transition window of 150 milliseconds.
Word Bank (Drag items below):
400
150
"150ms"
from microbit import *
while True:
display.show("GO", Drop here)
1.10. Question 10
Complete this script which prevents an integer variable from exceeding a ceiling of 9 when Button A is pressed.
Word Bank (Drag items below):
min
limit
max
from microbit import *
guess_number = 5
while True:
if button_a.was_pressed():
guess_number = Drop here(9, guess_number + 1)
display.show(guess_number)