Rocket sets three paper cups on the table. He names them score, lives, and level.
"Score holds zero," Rocket says. "Lives holds three. Level holds one."
Raven watches the game begin. "What do you notice when something happens?" she asks.
Nova hums. "Each event changes one cup," she says. Let's update each cup as the game goes on.
Imagine three paper cups. Each cup has a name. Right now each cup holds a number.
score = 0 lives = 3 level = 1
After Rocket scores a goal:
After Raven loses a life:
After both finish a level:
A program can have many variables. Each one has its own name, so they never mix up.
Change one box, and the other boxes stay the same.
score = 0 lives = 3 level = 1 score = score + 5 lives = lives - 1
| Statement | True or false? |
|---|---|
| Changing score also changes lives. | ? |
| Each variable has its own name. | ? |
| lives = lives - 1 takes one away from lives. | ? |
| score = score + 5 makes score go down. | ? |