Codepiko · World 4: Modern Software
Boxes and recipes
Goal: Follow a variable step by step, and name steps to use them again (a function).
Time: 25 min · You need: Pencil
Name:
Class:
Date:
1. The number in the box
A variable is a labelled box that holds a value. After each line runs, write what is in the boxes in the table.
| Line | score | lives |
|---|---|---|
| score = 0 | ||
| lives = 3 | ||
| score = score + 5 | ||
| score = score + 5 | ||
| lives = lives − 1 | ||
| score = score − 2 |
2. A move function
The function called dance does three moves. How many moves happen when the program runs? Then write your own function for a friend to act out.
function dance():
jump
spin
clapProgram: dance() sit dance()
Total moves:
Your own function
codepiko.com