Lesson 3.1: Variables
Learning Objectives
Students will be able to...
- Use variables to track values throughout a program
Materials/Preparation
- Lab 3.1 handout - Guessing Game (Download in Word) (Link to PDF)
Pacing Guide
Duration | Description |
---|---|
5 minutes | Welcome, attendance, bell work, announcements |
15 minutes | Lecture and introduce activity |
25 minutes | Activity - Guessing Game |
10 minutes | Debrief and wrap-up |
Instructor's Notes
Lecture
- Review user input, specifically the
block
- Ask students to speculate about how the
block works
- Students should recognize that the block must be storing a value somehow and remembering it for later
- Ask students whether that type of functionality might be useful in other cases
- Ask students to speculate about how the
- Introduce variables
- Define and explain the concept of a variable
- a "place" to store a value for retrieval and use later
- Demonstrate creating, assigning, and accessing a variable in SNAP
- Ignore global vs. this sprite only for now
- Point out that a variable can only hold one value at a time
- When a new value is assigned, the old value is lost and cannot be recovered
- Emphasize the importance of descriptive, readable names for variables
- Show that variables are independent
- One variable's value can be assigned to another, as in
, but changing the value of
var2
later will not update the value ofvar1
- One variable's value can be assigned to another, as in
- Define and explain the concept of a variable
- Review user input, specifically the
Activity
- Briefly demonstrate the
block, which will be used in the lab
- Direct students to complete Guessing Game individually or in pairs
- Briefly demonstrate the
Debrief
- Discuss and demonstrate one or more students' submissions
- Ask students for commentary on usage and naming of variables throughout program
Accommodation/Differentiation
- Advanced students can be encouraged to implement statistics (best score, average guesses/game, number of time each secret number chosen, etc.)
- Struggling students can be given code that completes part 1.1, and possibly also part 1.2, to get them started
- Students who are particularly overwhelmed should focus only on parts 1.2 and 2.2