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):
show
scroll
import
include

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
is_pressed
has_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):
write
show
in
range
of

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):
"400"
1
400
3
delay=400
2

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
else if
finish
if
elif

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
wait
pause
is_pressed
was_pressed
cleared

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):
50
"50"
delay=500

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 the characters of the string step-by-step.
Word Bank (Drag items below):
;
levels
:
char

from microbit import *

Drop here = "level 1 to 9"
for char 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):
150
400
"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):
limit
min
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)