Lesson 21: Changing Variables with 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 might be unknown at the time that you run your program or for values that can change during the execution of a program. These are vital to creating dynamic code because they allow your program to change and grow based on any number of potential modifications. This stage reinforces the use of variables, using the most basic capabilities of setting and using them.

Agenda

Warm Up (5 min)

Main Activity (20 min)

Wrap Up (15 min)

View on Code Studio

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

  • Play through the lesson to find any potential problem areas for your class.
  • Make sure every student has a journal.

Links

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

For the Students

Vocabulary

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

Support

Report a Bug

Teaching Guide

Warm Up (5 min)

Introduction

It might be helpful to remind students of "Variables that Change in Bee," since variables will be used in a similar way here.

  • How can we change the value of a variable inside of a loop?
  • Do we have to change the value of a variable only by one each time?

Main Activity (20 min)

Online Puzzles

The latter half of this series is made up of freeplay puzzles. Students will have the opportunity to play with variables, shape, and color to create something unique.

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?
  • Have you tried mixing multiple variables into one program? What might that look like? When would it be helpful?
View on Code Studio

Student Instructions

Let's start this section by drawing a triangle with 150 pixel sides.

Be sure to use the length variable and a repeat loop.

View on Code Studio

Student Instructions

Rebuild the triangle code from the last puzzle, but this time use the set length to block to reset the length variable to length+10 at the end of each loop iteration.

length ADD length 10

The length of the first side of the triangle is 150 pixels.

View on Code Studio

Student Instructions

Time to make some art!

See what happens when you repeat the code from the last puzzle 30 times instead of only 3!

Feel free to make your lines any color or pattern for some extra zest.

View on Code Studio

Student Instructions

Here's your code from the last puzzle. Try editing the variable in other ways.
- What happens if you start out with length less than 150? - What if you multiply your variable by 1.25 each time through? - What will your code do if you turn 119 degrees?

View on Code Studio

Teaching Tip

This level is a “free play”. These levels have some characteristics you may want to explore before starting.

  • These levels are not checked for correctness to allow for more open-ended creativity. Empower your students to determine for themselves when they have created something they like. There is no one right answer!
  • Example solutions are available for this level which can be viewed by opening the teacher panel to the right.

Student Instructions

Freeplay: Take what you've learned and make your own drawing.

How can you use variables with squares, pentagons, or hexagons?

View on Code Studio

Student Instructions

You just learned "variables"!

In order to use a variable, it needs a name and a value. The name doesn't change, but the value can. This way you can use the name of the variable as a placeholder wherever you want in your program!


Vocab to Know

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

View on Code Studio

Student Instructions

Challenge alert! Can you create a length variable and use it to create this interesting pattern?

View on Code Studio

Student Instructions

You've now learned everything you need to know to make a pattern like this! This puzzle is meant to be difficult. Can you stick with it until you figure out the solution?

Standards Alignment

View full course 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.