# Lesson 4: Writing Contracts

## Overview

Students will work their way through a number of new functions, first using each to solve a problem, and then writing a contract which describes it.

## Anchor Standard

### Common Core Math Standards

• 8.G.1 - Verify experimentally the properties of rotations, reflections, and translations:

## Objectives

### Students will be able to:

• Decompose existing functions.
• Write contracts that describe functions.
• Experiment with basic geometric transformations.

## Vocabulary

• Rotate - To turn a shape around a center point.
• Scale - To increase the dimensions of a shape by the same factor in all directions.
• Translate - To move a shape from one location to another.

# Teaching Guide

## Writing Contracts

### Online Puzzles

In this stage you'll be looking at some functions, some of which you've seen before and some which are brand new. For each function you'll first get a chance to use the function, and then you'll write a Contract for it. Make sure to document any new Contracts on your Contract Log. Head to Course A stage 4 in Code Studio to get started programming.

## Getting Started

### Introduction

Review with students the purpose of a Contract:

• Describes three elements of a function
• Name (what is the function called)
• Domain (what inputs does it take)
• Range (what does it output)
• As a class, describe the Contracts for some basic mathematical operators
• Addition (name +, domain Number Number, range Number)
• Subtraction (name -, domain Number Number, range Number)
• Multiplication (name *, domain Number Number, range Number)
• Power of two (name sqr, domain Number, range Number)
View on Code Studio

### Student Instructions

Use the `star` function to produce a solid red star with a 60 pixel radius

View on Code Studio

### Student Instructions

View on Code Studio

### Student Instructions

Check out the `rotate` function - can you use it to rotate this 90 pixel green square by 45 degrees?

View on Code Studio

### Student Instructions

View on Code Studio

### Student Instructions

Try using the `text` function to write this "Hello, world!" in teal at size 40.

View on Code Studio

### Student Instructions

View on Code Studio

### Student Instructions

The `scale` function returns an image that is either larger or smaller than the input image. Try scaling this circle by a factor of 10. How is the returned image different than if you'd just made a circle of that size in the first place?

View on Code Studio

## Standards Alignment

#### Common Core Math Standards

EE - Expressions And Equations
• 6.EE.9 - Use variables to represent two quantities in a real-world problem that change in relationship to one another; write an equation to express one quantity, thought of as the dependent variable, in terms of the other quantity, thought of as the independent va
• 7.EE.4 - Use variables to represent quantities in a real-world or mathematical problem, and construct simple equations and inequalities to solve problems by reasoning about the quantities.
F - Functions
• 8.F.1 - Understand that a function is a rule that assigns to each input exactly one output. The graph of a function is the set of ordered pairs consisting of an input and the corresponding output.1
G - Geometry
• 8.G.1 - Verify experimentally the properties of rotations, reflections, and translations:
IF - Interpreting Functions
• 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 c
• 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.
MP - 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
NS - The Number System
• 6.NS.8 - Solve real-world and mathematical problems by graphing points in all four quadrants of the coordinate plane. Include use of coordinates and absolute value to find distances between points with the same first coordinate or the same second coordinate.
OA - Operations And Algebraic Thinking
• 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 t
Q - Quantities
• N.Q.1 - Use units as a way to understand problems and to guide the solution of multi-step problems; choose and interpret units consistently in formulas; choose and interpret the scale and the origin in graphs and data displays.
• N.Q.2 - Define appropriate quantities for the purpose of descriptive modeling.
SSE - Seeing Structure In Expressions
• 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).