Lesson 2: A box with a name

Unit overview - Previous: Lesson 1 - Next: Lesson 3

About 45 minutes.

Goal

Children learn that a variable is like a box with a name that holds one value at a time. They run and trace programs that use SET, CHANGE ... BY and SAY, and say the final value.

Materials

Steps

Opening (5 min)

  1. Show the empty "score" box. Ask: "In a game, how does the game remember your score?" (Take ideas.)
  2. Say: "Programs keep things to remember in a variable. Think of it as a box with a name on it. The box holds one number at a time."
  3. Put the 0 card in the box. "The value of score is now 0."

Main activity (30 min)

Part 1: three cards (8 min). Teach the three cards:

Model Program A with the class, filling in the trace table:

SET score TO 0
CHANGE score BY 1
CHANGE score BY 1
SAY score
Step score
SET score TO 0 0
CHANGE score BY 1 1
CHANGE score BY 1 2
SAY score 2 (said aloud)

Part 2: groups run programs (14 min). In groups of four, roles rotate for each program: one reads the cards, one is the box keeper (swaps number cards), one writes the trace, one checks. Each group runs:

Then Program D, with a term 1 loop:

SET score TO 0
REPEAT 4 TIMES:
    CHANGE score BY 2
SAY score

(0, 2, 4, 6, 8; says 8.)

Part 3: one box, one value (8 min). Ask groups: "After Program C, where did the 3 go?" (It was taken out; the box only holds the newest value.) Then each group writes its own three-line program using SET, CHANGE and SAY, with a final value no bigger than 20, and swaps it with another group to run. The writers check the answer.

Discussion questions (with answers) (5 min)

Closing check (with answers) (5 min)

Children write the number that is said.

  1. SET score TO 4, CHANGE score BY 3, SAY score. (7)
  2. SET score TO 2, REPEAT 3 TIMES: CHANGE score BY 5, SAY score. (17)
  3. SET score TO 9, SET score TO 1, CHANGE score BY 1, SAY score. (2)

Vocabulary

variable, value, set, change, trace

Differentiation

Safety

Teacher notes and misconceptions