Lesson 8: Counter Pattern Unplugged
Overview
Students explore the underlying behavior of variables through an unplugged activity. Using notecards and string to simulate variables within a program, students implement a few short programs. Once comfortable with this syntax, students use the same process with sprite properties, tracking a sprite's progress across the screen.
Purpose
Reasoning about variables can be tricky, especially for new programmers. In this lesson students complete an unplugged activity using physical manipulatives (cards and string) to build a mental model of how information can be stored in a variable and manipulated by a program. This model is then extended to sprite properties, which hold values in a similar way. This lesson introduces syntax and concepts that students will be able to “plug-in” in the following lesson. The mental model presented in this lesson will continue to be useful throughout the unit, even as students begin to write larger and increasingly complex programs.
Agenda
Warm Up (15 mins)
Activity (20 mins)
Activity 2 (30 mins)
Wrap Up (10 mins)
View on Code Studio
Objectives
Students will be able to:
- Describe the connection between updating a sprite's location properties and sprite movement on the screen.
- Read and follow the steps of a short program written in pseudocode that manipulates variable values.
Preparation
- Prepare materials for Labels and Values: index cards, post-its, or scraps of paper (2 in. by 2 in.) etc. (~ 50 per pair)
- Prepare materials for Connectors: pieces of string, pens, or pipe-cleaners, etc. (~ 4 per pair)
- Print copies of Variables Unplugged Board - Manipulative for each group or gather paper for students to use to make their boards.
- Review the rules of the Variables Unplugged Activity to ensure you understand them and are prepared to answer questions, especially if you will be demonstrating them yourself.
- Printed a copy of Variables Unplugged - Activity Guide for each student.
Links
Heads Up! Please make a copy of any documents you plan to share with students.
For the Teachers
- Variables Uplugged - Key
For the Students
- Variables Unplugged - Activity Guide
- Variables Unplugged Board - Manipulative
Vocabulary
- Expression - Any valid unit of code that resolves to a value.
- Variable - A label for a piece of information used in a program.
Teaching Guide
Warm Up (15 mins)
Prompt: In the last lesson, we used the draw loop to make our sprites move around on the screen. What are some other ways we might want to make our sprites move?
Put student ideas up on the board.
Remarks
In the next few lessons, we're going to look at lots of ways to have our sprites move around. In order to do that, we need to learn a little bit more about variables and how they work. Today, we're going to do an activity with variables and sprite properties that will help us to make these types of movement. As we go through the activity, think about how what you're learning might help you to make your sprites move in the way you want.
Activity (20 mins)
Variables Unplugged Activity
Group: Put students in pairs.
Distribute: Give each pair:
1) A set of labels/values and connectors
2) A single sheet of paper to create their board
3) 2 copies of the Variables Unplugged - Activity Guide (One for each student.)
Display: Display the rules from the front page of the activity guide and write the first two programs from the second page.
Remarks
Today we are going to be working in a world of labels, values, and the connectors between them. To simulate this world you'll be using the scraps of paper and string that I've given you. To begin with we'll need to set up our boards, and afterwards we'll go over how the commands for this world work.
Demonstrate: Show the class how to divide their boards into 3 sections and label them accordingly, as shown on the first page of the activity guide.
Content Corner
This activity is designed to address many common misconceptions with variables and memory.
Common Misconceptions
- Variables can have multiple values (They cannot, variables hold at most one value)
- Variables “remember” old values (They do not, hence old values being removed to the Trash)
- Variables are connected after a command like “x = y” (This may arise later in the course when students use sprites and will be addressed in great detail. For now students are being forced to create new value cards every time because even for a statement like x = y there is no “connection” between those variables formed)
- Variables hold expressions (e.g. 1 + 5) (Variables only hold values, expressions are computed beforehand. This is why value cards are only created once students have a single value. Enforce this rule closely)
Support: Students should work through the first two programs as a group, as you reference the steps in the activity guide. As groups feel increasingly comfortable with completing commands themselves encourage groups to independently run each command before comparing their boards with a neighboring pair. The goal is just to make sure everyone has an opportunity to understand the steps of the activity.
Remarks
Now it's your turn to try running some of these programs on your own. On the bottom of the page there are two more programs that you can run. For each one you should run the program to find out the ending state of the program. In other words, you want to know what labels are connected to what values. Once you reach the end of each program you can compare your results with a neighboring group. If you don't agree, then go back though and see if you can find where you lost track.
Support: Students should work in pairs through the two programs on the activity guide. Have a check-in to make sure everyone agrees on the ending state of the program (what labels are connected to what values). If students disagree, reinforce the need to debug when reading code by going back and tracing each step.
Activity 2 (30 mins)
Sprite Properties
Distribute: Sprite Properties in Variables Unplugged - Activity Guide if you have not included it on the original activity guide.
Demonstrate: Show students the rules of activity on the activity guide. Work through program 5 as a group, and demonstrate how to make a new sprite card and connect it to both its variable label card and the sprite property cards. Make sure students understand that they should be creating a new sprite card every time they see the createSprite
command and should draw their sprites on the grid every time they see the drawSprites
command.
Support: Students should work through the last two programs using their manipulatives.
Discussion Goal
Goal: Students should see that commands such as x = x + 1
will move a sprite in a deliberate way across the screen, as opposed to the random movement they saw in the previous lesson.
Prompt: How did the sprite move across the grid in Program 3? How did the sprite move across the grid in Program 4?
After students have filled out the reflection questions, they should compare with another pair, then discuss as a class.
Wrap Up (10 mins)
Discussion
Discussion Goal
The goal of the discussion is not to have students think of solutions to all the problems, but for them to identify them, priming them for the counter pattern lesson. Some problems students may see are that the smiley faces remained on the screen, rather than moving, that they could only move left and right or up or down, or that the images stopped after a certain amount of time.
Prompt: We saw some clues today of how we might program the types of movement that we want for our sprites. What are some problems that we still need to solve to make the sprite look like it's moving in the way that you want?
Allow students to brainstorm problems and list them on the board.
Prompt: Choose one or two of these problems and start to think of some ways you could solve this problem.
Allow students time to brainstorm individually before sharing out their solutions.
Remarks
These are great ideas. In the next lesson, we're going to look at how we can use some of the things we've learned today to make our sprites move in lots of different ways.
- Lesson Overview
- Teacher Overview
- Student Overview
- Variables Unplugged - Activity Guide Key (PDF | DOCX)
Standards Alignment
View full course alignment
CSTA K-12 Computer Science Standards (2017)
AP - Algorithms & Programming
- 2-AP-10 - Use flowcharts and/or pseudocode to address complex problems as algorithms.
- 2-AP-11 - Create clearly named variables that represent different data types and perform operations on their values.