6
CS in Algebra | Lesson 6

Defining Variables and Substitution


Lesson time: 30-60 Minutes

Lesson Overview

In this activity, students will learn to define variables that can be used to reference values and expressions. Once defined, their variables can be used repeatedly throughout a program as substitutes for the original values or expressions.

Lesson Objectives

Students will:

Anchor Standard

Common Core Math Standards

Additional standards alignment can be found at the end of this lesson

Teaching Summary

Getting Started

1) Vocabulary
2) Introduction

Activity: Defining Variables and Substitution

3) Online Puzzles

Teaching Guide

Getting Started

1) Vocabulary

This lesson has two new and important words:

  • Define - associate a descriptive name with a value
  • Variable - a container for a value or expression that can be used repeatedly throughout a program

2) Introduction

Suppose we want to make an image with fifty identical, solid red triangles. To do so you'd have to create this Evaluation Block fifty times!

Even worse, if you decided you wanted fifty blue triangles instead, you'd have to go through and change each and every block. There must be a better way!

We can store that red triangle Evaluation Block in a Variable, let's call it "red-triangle." That name "red-triangle" now becomes a shortcut for the blocks inside the variable, and we can use that shortcut over and over in our program. If we decide that we want that red triangle to be 100 pixels instead of 50, we only need to change it in the variable definition.

Lesson Tip

If students have used variables in other programming languages, it's essential to note that in functional programming, as in math, variables are considered immutable - meaning the value can't be changed during the execution of a program. Think about it this way: saying x = 50, and then x = x + 1 might make sense in Javascript, but it's impossible in Algebra.

Activity: Defining Variables and Substitution

3) Online Puzzles

In this stage you'll use variables to reference a variety of values and expressions. Head to CS in Algebra stage 6 in Code Studio to get started programming.

Standards Alignment

Common Core Math Standards

  • 5.OA.1 - Use parentheses, brackets, or braces in numerical expressions, and evaluate expressions with these symbols.
  • 5.OA.2 - Write simple expressions that record calculations with numbers, and interpret numerical expressions without evaluating them. For example, express the calculation “add 8 and 7, then multiply by 2” as 2 × (8 + 7). Recognize that 3 × (18932 + 921) is three times as large as 18932 + 921, without having to calculate the indicated sum or product.
  • 6.EE.4 - Identify when two expressions are equivalent (i.e., when the two expressions name the same number regardless of which value is substituted into them). For example, the expressions y + y + y and 3y are equivalent because they name the same number regardless of which number y stands for.
  • A.SSE.1 - Interpret expressions that represent a quantity in terms of its context.
  • A.SSE.2 - Use the structure of an expression to identify ways to rewrite it. For example, see x4 – y4 as (x2)2 – (y2)2, thus recognizing it as a difference of squares that can be factored as (x2 – y2)(x2 + y2).
  • A.CED.1 - Create equations and inequalities in one variable and use them to solve problems. Include equations arising from linear and quadratic functions, and simple rational and exponential functions.
  • A.CED.2 - Create equations in two or more variables to represent relationships between quantities; graph equations on coordinate axes with labels and scales.
  • F.IF.1 - Understand that a function from one set (called the domain) to another set (called the range) assigns to each element of the domain exactly one element of the range. If f is a function and x is an element of its domain, then f(x) denotes the output of f corresponding to the input x. The graph of f is the graph of the equation y = f(x).
  • F.IF.2 - Use function notation, evaluate functions for inputs in their domains, and interpret statements that use function notation in terms of a context.
  • F.IF.3 - Recognize that sequences are functions, sometimes defined recursively, whose domain is a subset of the integers. For example, the Fibonacci sequence is defined recursively by f(0) = f(1) = 1, f(n+1) = f(n) + f(n-1) for n ≥ 1.
  • F.LE.1 - Distinguish between situations that can be modeled with linear functions and with exponential functions.

Common Core Math Practices

  • MP.1 - Make sense of problems and persevere in solving them.
  • MP.2 - Reason abstractly and quantitatively.
  • MP.3 - Construct viable arguments and critique the reasoning of others.
  • MP.4 - Model with mathematics.
  • MP.5 - Use appropriate tools strategically.
  • MP.6 - Attend to precision.
  • MP.7 - Look for and make use of structure.
  • MP.8 - Look for and express regularity in repeated reasoning.

Derived from