Lesson 22: Variables in Artist

Variable | Artist

Overview

In this lesson, students will explore the creation of repetitive designs using variables in the Artist environment. Students will learn how variables can be used to make code easier to write and easier to read. After guided puzzles, students will end in a freeplay level to show what they have learned and create their own designs.

Purpose

Variables are essentially placeholders for values that are unknown at the time that you run your program or for values that can change during the execution of a program. These constructs are vital to creating dynamic code because they allow your program to change and grow based on any number of potential modifications. This stage teaches students what variables are, using the most basic capabilities of setting and using them.

Agenda

Warm Up (15 min)

Bridging Activity - Variables (15 min)

Main Activity (30 min)

Wrap Up (15 min)

Objectives

Students will be able to:

  • Assign values to existing variables.
  • Utilize variables in place of repetitive values inside of a program.
  • Use variables to change values inside of a loop.

Preparation

Links

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

For the Teacher

For the Students

Vocabulary

  • Variable - A placeholder for a piece of information that can change.

Support

Report a Bug

Teaching Guide

Warm Up (15 min)

Introduction

This is the first online lesson dealing with variables, so it might be a worthwhile exercise to review the "Envelope Variables" unplugged activity from last time, as well as the vocabulary that was introduced in that lesson.

  • What is a variable? (A placeholder for a piece of information that can change.)
  • When can a variable be helpful? (When you don't know what information is going to be used in a certain place until runtime, or when you have lots of places that one piece of information will be used, but that information might change someday.)

Ask the class when they could see a variable being helpful in programming. When would they NOT want to use a variable?

If the class seems interested, continue the discussion. Otherwise, move on to one of the bridging activities.

Bridging Activity - Variables (15 min)

This activity will help bring the unplugged concepts from "Envelope Variables" into the online world that the students are moving into. Choose one of the following to do with your class:

Unplugged Activity Using Paper Blocks

Start with a sentence or paragraph on the board that contains at least one (and up to five) named blanks. Give paper blocks to each student group. Challenge each group to "set" their variables for each blank. Call on different student groups to share their assignment of each variable and see what happens!

Now, change the sentence to a math equation. What happens to the sentence "X + Y =" when students assign different values to the variables X & Y?

Preview of Online Puzzles as a Class

Display a puzzle to the class. We recommend the 3rd puzzle. Build the code the long way first (use exact numbers for each value, instead of utilizing variables) then suggest that you should try making the squares only 50 pixels. What a pain! What have students learned that will let them give something a name and use it as often as they want later in the program? Go back and add a variable to the beginning. Set the variable to 80, and substitute all occurrences of 80 in the program. Next, change it to 50. That was easy!

Main Activity (30 min)

CSF Express Course - Website

Notice that this stage first covers the idea of a variable as a constant (a variable that you use in many places, but it does not change.) Once that idea has been presented, it flips to show how you can include a variable for information that changes after the program is run.

Watch out for puzzle #5. It is the first time that students will be expected to set a variable on their own. This can be tricky if they don't have a true grasp on the concept. If they're having trouble, send them back to the prediction level (#4) and have them explain to their partners why the answer ended up what it was. Once both partners are convinced, let them continue back to puzzle #5.

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 is a variable? Why is it helpful in programming?
  • How well do you think you understand variables? (Answer on a scale from 1-5 or with an emoticon.) If you're having troubles, can you put into words what you don't understand?

Standards Alignment

View full course alignment

CSTA K-12 Computer Science 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.