There are two buttons on the front of the micro:bit (labelled A and B).

Handling an event

If we want MicroPython to react to button press events we should put it into an infinite loop and check if the button is_pressed.

from microbit import *

while True:
    if button_a.is_pressed():
        display.show(Image.HAPPY)
    else:
        display.show(Image.SAD)

DIY

Program the micro:bit to scroll the A letter if the A button is pressed and to scroll the B letter if the B button is pressed.

DIY

Complete the program: the program must scroll « AB » if both buttons is pressed.

Help: and, or and not could be use in test: if ((a) and not(b):