A box with a name ๐ฆ
You have coded with loops, events and if-then. Now meet the variable.
A variable is like a box with a name on it. Inside the box is a value, like a number. The program can look in the box, and it can change what's inside.
- set balls_out to 0 puts 0 in the box at the start.
- change balls_out by 1 adds 1.
- change balls_out by โ1 takes 1 away.
Games use variables for scores, lives and timers. Room 7 wants to use one to count how many balls are out at recess. They will use a small coding board with two buttons, A and B (such as a micro:bit).