Microbit
Beginner
40 mins
Teacher/Student led
+130 XP
Pupils work on their own device

Studio: Rock, Paper, Scissors in Python

Students build a Rock-Paper-Scissors game in the micro:bit Python editor using lists, randomness, button input and conditionals, tracing a round by hand before they run and debug.

Teacher Class Feed

Load previous activity

    1 - Start: What We're Building ~4 mins

    Illustration for Start: what we're buildingToday 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?

    2 - The Plan: Five Parts to Build ~3 mins

    Rock, Paper, Scissors in Python has five parts:

    1. Import the modules you need.
    2. A list of the three choices.
    3. The player's choice, taken as input.
    4. The computer's choice, picked at random from the list.
    5. The rules that decide who won.

    The rules are the part to think about before you type: there are only nine possible rounds, and three of them are draws.


    3 - Import Modules ~2 mins

    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 random
    This imports everything from microbit and the random module. Run the code; nothing will happen yet, but it should run without errors.
    If you see any import errors, check your spelling and ensure you're using the online editor.

    4 - Define Choices List ~3 mins

    Next, 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")
    Avoid copy-pasting the code. Type each line to master the code’s logic and structure.
    Run the code. You should see 'Ready' scroll on the display. This confirms the list is set up. The list 'choices' now holds three string items. We'll use it later for random selection.
    Try adding display.scroll(choices[0]) after the list to show 'rock'. This practises accessing list elements.
    123learn · Online learning platform

    Unlock the full learning experience

    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.

    Hundreds of curriculum-aligned lessons
    Interactive activities in every lesson
    Printable resources & progress tracking
    Copyright Notice
    This lesson is copyright of Coding Ireland 2017 - 2026. Unauthorised use, copying or distribution is not allowed.
    🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more