Skip to content
Exit presentation

Programming with Blocks II

A box with a name on it

A game must count mangoes. It needs a place to keep the number.

An empty box. No name yet.
Step 1 of 4
  1. An empty box. No name yet.
  2. Name it score.
  3. Set score to 5. That puts 5 in the box.
  4. Set score to 9. The 5 is gone.

A variable is a named box. It holds a value. In this track, values are numbers.

You pick the name: score, lives, mangoes. Blocks use the name to find the box. Lives are the chances a player has left. The computer does not know what the name means.

Rule: A variable is a named box. It holds one value at a time. Setting it replaces what was there.

Make score hold 5 and lives hold 2. Tap the buttons in any order.

Loading lab…

Jump to lesson

This track

  1. 0 Start here
  2. 1 A box with a name on it
  3. 2 Changing what is in the box
  4. 3 Waiting for something to happen
  5. 4 One block inside another
  6. 5 Plan it before you build it
  7. 6 The big picture
  8. 7 Track quiz

Other tracks