Skip to content

Random Activity: Challenges

Level Beginner
Board V1 & V2
Parts micro:bit

What you'll build

A party-game picker: press button A and the micro:bit scrolls a random challenge.

Code

8 random-lib2.py
1
2
3
4
5
6
7
8
from microbit import *
import random

challenges = ["joke", "jump", "truth/dare", "drink"]

while True:
    if button_a.is_pressed():
        display.scroll(random.choice(challenges))

How it works

random.choice(list) returns one item from the list at random. Edit the challenges list to make your own game.

Try this next

  • Add your own challenges to the list.
  • Use button_a.was_pressed() so one press gives exactly one challenge.
  • Send the challenge to a friend's micro:bit over radio.