Skip to content

    Variable Valley

    Year 2 Variables

    Store a score in a variable, change it step by step, and work out its value at the end.

    • Ages 6–8
    • 3 quests
    • Beginner → Getting stronger → Challenge

    A variable is a labelled box that stores a value, like a score or a number of lives. Programs can set a variable and change it as the program runs. Year 2 coders trace short programs to find a variable’s final value.

    What your child will learn

    • Know that a variable stores a value with a name
    • Follow “set” and “change” blocks step by step
    • Work out the final value of a variable

    Keeping score

    Every game with a score uses a variable. “Set score to 0” starts it; “change score by 1” adds one each time you collect a star. Working through a program one line at a time — tracing it — is how programmers check what a variable will be.

    Example questions

    Here are a few questions like the ones in the first quest. Can you solve them?

    1. 1. What is lives at the end?

      • 5
      • 9
      • 10
      • 11
      Show answer

      Answer: 10. lives starts at 5. 5 + 5 = 10. So lives ends at 10.

    2. 2. What is coins at the end?

      • 2
      • 1
      • 4
      • 3
      Show answer

      Answer: 2. coins starts at 4. 4 − 2 = 2. So coins ends at 2.

    3. 3. What is apples at the end?

      • 1
      • 0
      • 2
      • 3
      Show answer

      Answer: 0. apples starts at 3. 3 − 3 = 0. So apples ends at 0.

    4. 4. Put the coin program in order.

      • change coins by 1
      • collect a coin
      • set coins to 0
      • say coins
      Show answer

      Answer: set coins to 0 → collect a coin → change coins by 1 → say coins. Set the variable first, then change it, then show it.

    Tips for grown-ups

    • Keep score in a board game on paper and talk about “changing score by 2”.
    • Use a box labelled “sweets” and add or take away while counting.