# Lesson 16: Changing Variables with Bee

## Overview

This lesson will help illustrate how variables can make programs more powerful by allowing values to change while the code is running.

## Purpose

You don't always know what a value is going to be before you begin your program. Sometimes, values change while your code is running. This lesson will illustrate how code with changing values can be helpful.

## Objectives

### Students will be able to:

• Identify areas where they can use variables to modify quantities during runtime.
• Examine code to find places where variables can be substituted for specific values.

## Preparation

Heads Up! Please make a copy of any documents you plan to share with students.

## Vocabulary

• Variable - A label for a piece of information used in a program.

# Teaching Guide

## Warm Up (15 min)

### 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: Suppose all of the flowers/honeycomb in this picture had the same amount of nectar/honey. How would you solve this puzzle?

Share: Let students share their ideas until you decide on one that the entire class is good with.

Discuss: Now, imagine that we didn't want to have to write a separate chunk of code for each set of flowers and honeycomb. How could we use a variable to have our loop do this for us?

(Eventually, you'll want to get to the place where you initialize a variable to the original value, then change it each time through the loop so that it's ready for the next time.)

## Main Activity (30 min)

### Course F Online Puzzles - 2018 - Website

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?
• What would it look like without the functions?
• Now how can you use a variable to get the quantities the way you want them?
• Now can you build it back up to use a function?

Hint: Puzzle 7 becomes much easier if students utilize the `while path ahead` loop instead of a variable.

## Wrap Up (15 min)

### Journaling

Having students write about what they learned, why it’s useful, and how they feel about it can help solidify any knowledge they obtained today and build a review sheet for them to look to in the future.

#### Journal 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?

## Standards Alignment

#### CSTA K-12 Computer Science Standards (2017)

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.

## Cross-curricular Opportunities

This list represents opportunities in this lesson to support standards in other content areas.

#### Common Core English Language Arts Standards

L - Language
• 5.L.6 - Acquire and use accurately grade-appropriate general academic and domain-specific words and phrases, including those that signal contrast, addition, and other logical relationships (e.g., however, although, nevertheless, similarly, moreover, in addition).
SL - Speaking & Listening
• 5.SL.1 - Engage effectively in a range of collaborative discussions (one-on-one, in groups, and teacher-led) with diverse partners on grade 5 topics and texts, building on others’ ideas and expressing their own clearly.
• 5.SL.1.a - Come to discussions prepared, having read or studied required material; explicitly draw on that preparation and other information known about the topic to explore ideas under discussion.

#### Common Core Math Standards

MP - Math Practices
• MP.1 - Make sense of problems and persevere in solving them
• MP.6 - Attend to precision
• MP.7 - Look for and make use of structure
• MP.8 - Look for and express regularity in repeated reasoning

#### Next Generation Science Standards

ETS - Engineering in the Sciences
ETS1 - Engineering Design
• 3-5-ETS1-1 - Define a simple design problem reflecting a need or a want that includes specified criteria for success and constraints on materials, time, or cost.