Rock, paper, scissors

Shake to throw rock, paper or scissors: learners use a random number and if, else if and else to choose a picture.

Go to the code ↓

Lesson at a glance

45 to 60 minutes · Grades 4 to 6

maze.education/microbit/lessons/rock-paper-scissors

Grades
Grades 4 to 6
Time
45 to 60 minutes
The CAPS gives Coding and Robotics 2 hours a week (Coding and Robotics CAPS, Grades 4 to 6, page 22).
Level
Some experience
For classes that have used the micro:bit and MakeCode once or twice.
Board
Any micro:bit
Code with
MakeCode and Purple Mash blocks, with Python as an extension
CAPS
Coding and Robotics, Mathematics
Aligned: Grade 6, Term 2 · Where it fits

Learning intentions

Learners will learn to:

  1. Use if, else if and else to choose between three outcomes.
  2. Link each random number to a picture, the way a game links rules to actions.
  3. Explain why the game is fair when each choice has the same chance.

Success criteria

Each learner can say:

  • I can use if, else if and else so that the program picks one of three pictures.
  • I can say which number stands for rock, which for paper and which for scissors in my program.
  • I can explain why each choice has a 1 in 3 chance.

Competencies

From the Coding and Robotics CAPS places this lesson cites.

  • C.2Present a simple coding solution
  • C.3Interpret and execute a given symbolic or written set of commands
  • R.5Design a simple artefact based on a set of design instructions

Key words

condition
A question with a yes or no answer, such as: is hand equal to 1?
if, else if, else
Blocks that choose which instructions to run, depending on conditions.
random
Chosen by chance.
variable
A named box in the computer's memory that holds a value.
flowchart
A diagram of the steps and decisions in a process, read from the top.

What you need

  • One micro:bit per learner, so pairs can play against each other
  • A computer with Chrome or Edge for each learner or pair
  • A score sheet for each pair

From our shop: BBC micro:bit V2 Go, BBC micro:bit V2.21 Next Gen Classroom Pack

Safety

  • Shake the micro:bit with the battery holder held firmly in the same hand, so neither flies off.
  • Clear a safe space first: no bags on the floor, and enough room for everyone to move without bumping into each other.
  • Use the battery holder with two AAA batteries. Never mix old and new batteries, and take the batteries out before the kits are packed away.

The lesson plan

One lesson of 45 to 60 minutes in three parts: introduction, lesson development and consolidation. The CAPS gives Coding and Robotics 2 hours a week, so it fits one of the week's lessons. Times are a guide.

  1. Introduction

    5 to 10 minutes
    Retrieval practice

    What does an IF…THEN statement do? (It checks a condition, and runs some steps only when the answer is yes.)

    Problem statement

    When two groups both want the netball court at break, they settle it with rock, paper, scissors, and someone always says the other side threw late. Build a thrower that picks by chance when you shake it, and check that it is fair.

    1. Play a quick round of rock, paper, scissors with the class. Ask a learner to explain the rules, and write them as if sentences: if I show rock and you show scissors, then I win.
    2. Read the problem statement together. Ask: what makes a throw fair?
  2. Lesson development

    35 to 40 minutes
    1. Unplugged first. Make three cards numbered 1, 2 and 3 and agree that 1 is rock, 2 is paper and 3 is scissors. A learner picks a card without looking, and the class says which hand to show. That is exactly what the program will do.
    2. Plan on paper first. Pairs draw a flowchart: a shake, a random number from 1 to 3, then the questions in order. Is it 1? Is it 2? Otherwise it must be 3.
    3. Predict. Ask: how many questions does the program need to ask for three choices? What will show if the random number is 3?
    4. Build in blocks. Pairs share one computer. The driver builds the program from the Blocks tab; the navigator follows the flowchart and checks that each question is in the right order. Swap roles halfway, at the if then else block.
    5. Test and debug. Shake several times in the simulator. Do all three pictures appear? If one never shows, compare the conditions with the flowchart.
    6. Download it, then play best of ten against a partner and keep score on the sheet. Discuss: does each player have the same chance of winning? Why?

    Plan on paper: a model answer

    In pairs, draw the thrower as a flowchart, from the shake to the picture.

    Flowchart
    1. The micro:bit is shaken
    2. Set hand to a random number from 1 to 3
    3. Is hand 1?Yes: show rock (a filled square)No: ask the next question
    4. Is hand 2?Yes: show paper (the outline of the display)No: show scissors
    5. Wait for the next shake
  3. Consolidation

    5 to 10 minutes
    1. Ask: what would happen if the random block picked 1 to 4?
    2. Ask: why do we only need to test two conditions for three choices?
    3. Back to the problem: a pair shares their final score. Was it close? Would the two groups accept the thrower as fair, and why? Learners check themselves against the success criteria.

Build it, step by step

Pairs build the program in blocks, following the numbered steps, with the same program as text beside them to check against or paste. Test in the simulator before sending it to a board.

A shake picks hand, a random number from 1 to 3: 1 shows rock (a filled square), 2 shows paper (the outline of the display) and anything else shows the scissors icon.
if, else if and else link each random number to one picture, and each picture has a 1 in 3 chance.

These are the MakeCode steps. The other routes are on the lesson's web page.

Build it in MakeCode blocks

  1. Start a New Project and make a variable called hand in Variables.
  2. From Input, drag in on shake.
  3. From Variables, put set hand to inside it, with pick random 1 to 3 from Math.
  4. From Logic, drag in an if then else block. Click the plus sign to add an else if.
  5. In the first condition, put a 0 = 0 compare block from Logic and make it hand = 1. In the else if, make it hand = 2.
  6. Put a show leds from Basic in the first two parts, a filled square for rock and an outline for paper, and show icon with the scissors in the else part.
  7. Test with SHAKE in the simulator, then Download.
The same blocks as text (to paste into MakeCode)
let hand = 0
input.onGesture(Gesture.Shake, function () {
    hand = randint(1, 3)
    if (hand == 1) {
        basic.showLeds(`
            . . . . .
            . # # # .
            . # # # .
            . # # # .
            . . . . .
            `)
    } else if (hand == 2) {
        basic.showLeds(`
            # # # # #
            # . . . #
            # . . . #
            # . . . #
            # # # # #
            `)
    } else {
        basic.showIcon(IconNames.Scissors)
    }
})

To use the text instead: open MakeCode, start a new project, click JavaScript at the top, replace what is there with this code, then click Blocks to see it as blocks.

To send it to the board, click Download. In Chrome or Edge, MakeCode can connect to the micro:bit by USB so the program goes straight onto it. Otherwise a .hex file downloads: drag it onto the MICROBIT drive.

Extension or homework

Challenges for learners who finish early, or to take further in a club or as homework.

  1. Challenge 1

    Play against a partner's board by radio: each board sends its choice, and both show who won.

  2. Challenge 2

    Play 30 rounds and tally how often each choice comes up. Is the micro:bit fair?

  3. Challenge 3

    Show the choice as a short animation before the final picture, so the throw feels like a real game.

Support and extension

Support

For learners who need more help

  • Give out the program with the pictures already drawn, so learners only build the random number and the if blocks.
  • Use three icons instead of drawing with show leds.

Extension

For learners who are ready for more

  • Add a score: make a variable called wins, and press A to add one and B to show it.
  • Add a fourth choice (lizard? spock?) and write the new rules.

Informal assessment

Ask these as learners work. Informal assessment happens every day and is not recorded.

  1. What is a condition? Give an example from the program.
  2. When does the else part run?
Exit question

What is the chance of throwing rock on one shake?

Observation checklist

Watch pairs as they plan, build and test. Write each pair's initials under the level you see.

Watch forBeginningDevelopingAccomplishedExemplary
Draws the decisions in the right order before building.
Builds if, else if, else with the right number in each condition.
Predicts what shows for each number, then tests all three.
Explains the 1 in 3 chance in their own words.
Beginning:
not yet, even with help
Developing:
with help
Accomplished:
on their own
Exemplary:
on their own, and explains it or takes it further

The four levels are the CAPS rubric levels (Coding and Robotics CAPS, Grades 4 to 6, page 176). The short descriptions are ours.

This lesson is not a formal task, but it is good practice for the term's practical task in Grades 4 to 6 (Coding and Robotics CAPS, Grades 4 to 6, page 170).

Common mistakes and fixes

  • Problem: Scissors never appear.Fix: Check the random block says 1 to 3, not 1 to 2.
  • Problem: Only one picture ever appears.Fix: Both conditions may say hand = 1. Change the second one to hand = 2.
  • Problem: The pictures flash past too fast to see.Fix: Shake once, then hold still. Each shake throws again.

Where it sits in CAPS

  • Coding and RoboticsAlignedGrade 6, Term 2: decisions with IF, THEN and ELSE.Source: Coding and Robotics CAPS, Grades 4 to 6 (opens in a new tab), Grade 6, Term 2, Coding, C.3 Interpret and execute a given symbolic or written set of commands, page 139: Two variables with IF…THEN…ELSE
  • Coding and RoboticsAlignedGrade 6, Term 2: a rock, paper, scissors game on the micro:bit.Source: Coding and Robotics CAPS, Grades 4 to 6 (opens in a new tab), Grade 6, Term 2, Robotics, R.5 Design a simple artefact based on a set of design instructions, page 143: Rock-Paper-Scissors
  • Coding and RoboticsFitsGrade 4, Term 2: IF…THEN to choose what happens (the CAPS teaches it with on-screen sprites in Grade 4; this lesson goes on to else if and else).Source: Coding and Robotics CAPS, Grades 4 to 6 (opens in a new tab), Grade 4, Term 2, Coding, C.2 Present a simple coding solution using symbolic or written statements representing sequences of commands, single repetition, and conditional constructs, page 67: Introduce simple IF…THEN statement formally
  • MathematicsGrades 4 to 6 Mathematics: listing the possible outcomes of a repeated event.Source: CAPS Mathematics, Grades 4 to 6 (opens in a new tab), Section 2, topic 5.4 Probability (Grades 4, 5 and 6): Perform simple repeated events and list possible outcomes

Coding and Robotics quotes come from the Department of Basic Education's final CAPS, with the page number of the 2024 printed edition (the Department's October 2025 library copies number their pages differently). Schools may teach a topic in another term: the CAPS leaves the order to each school's annual teaching plan.

Ready to teach it?

Get a micro:bit for every learner or pair, and let us train your staff to run lessons like this one.

More lessons

All lessons →
  • Grades 4 to 6

    Grades 4 to 645 to 60 minLevel: Getting started

    Shake-to-roll dice

    Shake the micro:bit to roll a number from 1 to 6, then roll 60 times and test whether the dice is fair.

    Subjects: Mathematics · Coding and Robotics

    Code with: MakeCodePurple MashPython

  • Grades 4 to 6

    Grades 4 to 645 to 60 minLevel: Some experience

    Times-table true or false

    The micro:bit shows a times-table fact that may be wrong: A for true, B for false, and a score after ten questions.

    Subjects: Mathematics · Coding and Robotics

    Code with: MakeCodePython

  • Grades 4 to 6

    Grades 4 to 645 to 60 minLevel: Some experience

    Compass

    Learners turn the micro:bit into a compass that shows N, E, S or W, then use it to map their school grounds.

    Subjects: Social Sciences · Coding and Robotics

    Code with: MakeCodePython

micro:bit is a trade mark of the Micro:bit Educational Foundation, and BBC is a trade mark of the British Broadcasting Corporation. Maze Education is an independent reseller of genuine BBC micro:bit products. Our teacher training and our other products and services are our own, and are not endorsed by the Foundation or the BBC.

WhatsApp