Lesson 12: Variables with the Bee
60 minutes
Overview
This skill-building lesson will help illustrate how variables can make programs more dynamic by allowing values to change while the code is running.
Purpose
This lesson will illustrate how code with changing values can be helpful and prepare students to understand how "for" loops work in upcoming lessons.
Standards
AP - Algorithms & Programming
- 1B-AP-09 - Create programs that use variables to store and modify data.
- 1B-AP-11 - Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process.
Agenda
Objectives
Students will be able to:
- Examine code to find places where variables can be substituted for specific values.
- Identify areas where they can use variables to modify quantities during runtime.
Preparation
- Play through the puzzles to find any potential problem areas for your class.
- Make sure every student has a reflection journal.
Vocabulary
- Variable - A label for a piece of information used in a program.
Teaching Guide
Warm Up (15 minutes)
Introduction
This series is a little different than what students have done in the past. Now, instead of simply assigning a value to a variable and running your code, you'll need to help students see how a variable can be modified during program runtime.
Display Show students the play area from one of the later puzzles.
There are several things to unpack here, so you might need to give your students a chance to look at it critically before you expect them to do anything with it.
Think/Pair: What patterns do you notice in this puzzle? What are the differences between the flower honeycomb patches at the beginning, middle, and end of the bee's path?
Share: Let students share their ideas.
Discuss: What are the ways we could program a solution to this puzzle? How could we use a variable to have a loop do this for us?
Main Activity (30 minutes)
Variables with the Bee
This set of puzzles takes some serious computational thinking skills. If you find that students are getting stuck, help them break down the puzzles into the individual pieces:
- What would it look like if the flowers/honeycomb all had the same amount of nectar/honey?
- Now how can you use a variable to get the quantities the way you want them?
Wrap Up (15 minutes)
Reflection
Prompts:
- What was today’s lesson about?
- How did you feel during today’s lesson?
- What are some ways you have used variables so far?
- What else do you think you can do with variables?
This work is available under a Creative Commons License (CC BY-NC-SA 4.0).
If you are interested in licensing Code.org materials for commercial purposes contact us.