0

The counting box

    1. 1
      start
    2. 2
      add 1
    3. 3
      add 1

    Counting as you go

    You pick apples one by one. Each time, you count one more. You remember the number in your head.

  1. set stars to 0
    say stars

    A box with a name

    The robot remembers numbers in a box. This box is called stars. Set stars to 0 puts a 0 inside. Say stars shows it.

  2. set stars to 0
    add 1 to stars
    add 1 to stars
    say stars

    Add 1 to the box

    Add 1 to stars makes the number one bigger. The box had 0. After two adds, it holds 2.

  3. set stars to 0
    move right
    collect the star
    add 1 to stars
    move right
    collect the star
    add 1 to stars
    say stars

    Count what you collect

    Each time the robot collects a star, it adds 1 to the box. At the end it says how many it got.

For parents

Goal: Your child learns that a program can keep a number in a named box (a variable), start it at 0, add 1 to it, and say what is inside.

  • Call it the counting box. The word variable can come later.
  • As the robot runs, ask: what number is in the box right now?
  • Point out that set stars to 0 always empties the box back to 0.

Away from the screen: Give your child a small cup and some beans. Say set to 0 and they empty the cup. Say add 1 and they drop in one bean. At the end, ask what is in the box.

Coding · The Counting Box
Back to top