Today you are coding in Python on the micro:bit editor. You will build a Rock-Paper-Scissors game step by step: predict what a round should do, then build, run and fix.
You can already use simple Python and make the micro:bit respond. By the end you will have a full game where you press buttons for rock, paper or scissors, the micro:bit picks at random, and the display shows who won.
Before you run anything, think: if you choose rock and the micro:bit chooses scissors, who should win, and what should appear on the screen?

Rock, Paper, Scissors in Python has five parts:
The rules are the part to think about before you type: there are only nine possible rounds, and three of them are draws.
In this step, we'll import the necessary modules. We need the microbit module for hardware access and the random module to generate the computer's choice.
Start by adding the following complete code to your editor:
from microbit import *
import randomNext, we'll create a list to store the possible choices: rock, paper, and scissors. Lists are great for holding multiple related items, and we'll use this to select the computer's choice randomly.
Update your code to the following complete version:
from microbit import *
import random
choices = ["rock", "paper", "scissors"]
display.scroll("Ready")
You're previewing this lesson. Get full access to this lesson and hundreds more — each one ready to teach, with interactive activities, printable resources and pupil progress tracking built in.