WorksheetsMicro:bit Programming Quiz
Total questions: 38
Worksheet time: 19mins
What does from microbit import * do?
Create a new program
Import functions from Micro:bit
Save the project
Restart Micro:bit
Which command will display a heart image on the Micro:bit screen?
display.show("HEART")
display.show(Image.HEART)
display.show("HEART", 3)
show.display(Image.HEART)
What is the function of the display.scroll("text") method?
Displays a text at the center of the screen
Displays text scrolling across the screen
Displays images
Turns off the screen
What type of loop runs code indefinitely on Micro:bit?
for loop
while True: loop
repeat loop
until loop
Which of these is a valid way to stop the Micro:bit program?
Pressing the reset button
display.clear()
break
stop()
What does button_a.is_pressed() return?
Number
Image
True or False
Text
How do you detect if button A was pressed?
if button_a.is_pressed():
if button_a.was_pressed():
if button_a.is_pushed():
if button_a.on_press():
What does button_b.was_pressed() check?
If button B is being pressed now
If button B was pressed since the last check
If button B is held down
If button A is pressed
To detect whether both button A and B are pressed at the same time, you would use:
if button_a.is_pressed() and button_b.is_pressed():
if button_a.was_pressed() and button_a.was_pressed():
if button_ab.is_pressed():
if button_a.is_pressed() or button_b.is_pressed():
In the game, how do you increase a number when button A is pressed?
number = number + 1
number += 1
number = number++
number = add(number, 1)
What is the purpose of a while True: loop in Python?
To run the code only once
To create an infinite loop
To exit the loop after one run
To repeat the loop a fixed number of times
How do you prevent a while True: loop from running endlessly?
Use a sleep() inside the loop
Use a break condition
Use if statements to exit
All of the above
Which command pauses the program for 1 second?
sleep(1000)
wait(1)
pause(1000)
sleep(1)
How do you stop a while True: loop immediately?
exit()
end()
break
continue
What will happen if there is no sleep() inside a while True: loop?
The Micro:bit will crash
The program will run slower
The program will consume a lot of power
The code will automatically restart
Which Python function generates a random number between 0 and 9?
random.choice(0, 9)
random.randint(0, 9)
random.random(0, 9)
random.get(0, 9)
If you want to generate a random number between 1 and 6 (like a dice), which code should you use?
random.randint(1, 6)
random.choice(1, 6)
random.number(1, 6)
random.range(1, 6)
What is the output of random.randint(5, 10)?
A number from 5 to 10, including 10
A number between 5 and 10, excluding 10
A random float number
An error
What is returned by the function running_time()?
Time since Micro:bit was turned on, in seconds
Time since program started, in milliseconds
Time elapsed from the last press
Time since the last loop ran
What is the correct way to measure elapsed time in milliseconds from when the program started?
start = running_time()
start = running_time(0)
start = time()
start = millis()
If you want to delay code execution for exactly 2 seconds, you should use:
sleep(2000)
delay(2)
wait(2000)
sleep(2)
How would you check how much time has passed since the start of the program?
running_time() - start
elapsed_time()
time_passed()
time()
What function helps you pause the program for a specific amount of time?
stop()
pause()
sleep()
delay()
What is the correct way to create a variable for the player's score?
score = 0
let score = 0
score: 0
score == 0
Which of these is a valid variable name?
score-player
score1
2score
Score!
How would you increase the value of a variable counter by 1?
counter++
counter += 1
counter.add(1)
counter = counter + 1
Which of the following is the correct way to count how many times button A is pressed?
if button_b.was_pressed():
press_count+=1
if button_a.was_pressed():
press_count+=1
if button.a.was_pressed():
press_count+1
if button_a.was_pressed():
press_count=+1
Which line resets the variable score to 0?
score = 0
reset(score)
score.clear()
score(0)
What is the correct syntax to check if score is greater than 10?
if score > 10:
if score > 10 then:
if score > 10 {
if (score > 10)
What will the following code display if light_level = 60? if light_level > 50: display.show(Image.HAPPY) else: display.show(Image.SAD)
Happy image
Sad image
Error
Nothing
What is the result of if x == 5:?
If x is 5, execute code
If x is greater than 5, execute code
If x is less than 5, execute code
If x is not equal to 5, execute code
What will happen if if temperature() > 25: is true?
Executes code inside the block
Executes code outside the block
Nothing happens
Program stops
Which code is correct for checking whether a number is positive?
if number > 0:
if number >= 0:
if number != 0:
if number < 0:
How do you display a smiley face on the Micro:bit screen?
display.show(Image.SMILE)
display.show("SMILE")
display.show(Images.SMILE)
show.display(Image.SMILE)
Which of these will display the text "HELLO" scrolling across the screen?
display.scroll("HELLO")
display.show("HELLO")
show.scroll("HELLO")
scroll.display("HELLO")
What is the function of display.clear()?
Clears all variables
Clears the text on the screen
Clears the program
Clears the timer
Which of these methods can be used to display an image?
display.show("image_name")
display.show(Image.NAME)
display.image("NAME")
display.show(TEXT)
How would you create a heart shape that stays on the screen?
display.show(Image.HEART)
display.scroll(Image.HEART)
display.show("HEART")
display.add(Image.HEART)
