Python microbit basics: How to display text

Extend it with code
How can you improve it?

Once you’ve mastered the basics of text you should have a a look at the documentation page to see what else is possible to display graphics and text to the micro:bit screen.

The display.scroll function has some optional parameters as well as the text that you want to display:

microbit.display.scroll(string, delay=150, *, wait=True, loop=False, monospace=False)

This means that if you want the message to keep looping around the screen you can try:

display.scroll(“Hello”, loop=True)

The code below creates a list of two strings (a string is some text), then randomly chooses one to display on the micro:bit screen:

Can you adapt the code to:

  1. Show (rather than scroll) a H or a T for heads or tails?
  2. Work as the sorting hat from Harry Potter (choose a random house from Ravenclaw, Gryffindor, Slytherin or Hufflepuff)?
  3. Say “Hello” in a random language?
  4. Tell one of three random jokes?


Leave a Reply

Your email address will not be published. Required fields are marked *