instagram

(Also available in WeScheme)

Students are introduced to the Design Recipe as a scaffold for breaking down word problems into chunks that will support them in writing code.

Lesson Goals

Students will be able to:

  • Understand how to use the Design Recipe to break down word problems.

  • Create a strong purpose statement that details in their own words what the function should do.

Student-Facing Lesson Goals

  • I can write my own function in Pyret.

  • I can use the Design Recipe to break down word problems when writing a function.

Materials

Preparation

  • Make sure all materials have been gathered

  • Decide how students will be grouped in pairs

Key Points for the Facilitator

  • The purpose statement is a comment in the code - something the computer doesn’t read. It is important for readability of their code - there may be other people looking at their code and using their functions!

  • Remind students that the domain and range of a function must be one or more of the data types (Number, String, Image, Boolean, etc.) they’ve learned so far.

  • If students struggle with creating the examples, use the Circle of Evaluation mapping activity or use role-playing to help students build up their understanding around the concept.

Click here to see the prior unit-based version

Glossary
contract

a statement of the name, domain, and range of a function

data types

a way of classifying values, such as: Number, String, Image, Boolean, or any user-defined data structure

design recipe

a sequence of steps that helps people document, test, and write functions

function

a mathematical object that consumes inputs and produces an output

purpose statement

a concise, detailed description of what a function does with its inputs

🔗The Design Recipe 10 minutes

Overview

In this lesson students build on what they already know about multiple representations of functions (contracts, examples and definitions) to write purpose statements and gain fluency with the Design Recipe.

Launch

Have students turn to Creating Contracts From Examples and write contracts for the examples provided.

Investigate

Of course, solving equations is something that calculators and computers can do for us! That’s where word problems come in: a word problem is a description of a situation, and the trick is to figure out the mathematical relationships that describe it. Figuring out the relationships that govern everything from the fuel efficiency of an engine to the best way to build a bridge is where math gets creative, applied, and fun!

But seeing the math behind the words can be challenging! In this lesson, you’re going to learn a strategy for breaking down word problems, called the Design Recipe.

You’ve actually seen most of the steps of the Design Recipe, but there’s one part you haven’t seen: writing a purpose statement. On its own, a contract is not enough information to generate examples and write a function definition. We need to know what the function is supposed to do with what it takes in. Programmers and Mathematicians alike find it helpful to restate a problem in their own words. After all, if you can’t explain a problem to someone else, you probably don’t understand it yourself!

Turn to Writing Examples from Purpose Statements and read the purpose statements. What do you notice? What do you wonder?

Debrief the notice and wonder as a class. Then have students write examples that satisfy each of the contracts and purpose statements on Writing Examples from Purpose Statements.

OPTIONAL: For more practice, have students complete Writing Examples from Purpose Statements 2.

Synthesize

What are the important elements of purpose statements? Why are purpose statements useful?

🔗Writing Linear Functions 25 minutes

Overview

Students are given a non-working program, which uses a linear function to determine the height of a rocket after a given length of time. The "broken" code is provided to lower cognitive load, allowing students to focus on comprehension (reading the code) and making use of structure (identifying where it’s broken).

Launch

Students should have their workbook, pencil, and be logged into code.pyret.org on their computer.

Ask students to open the rocket-height Starter File (Pyret) and click "Run". By typing start(rocket-height), they will see the simulation start to run on their computer.

Notice and Wonder

What do you notice about this program? What do you wonder?

Survey the class on their "Notices" and "Wonders" and record on the board before moving on to the discussion.

  • Is rocket-height working?

  • Why do you think it’s not working?

  • What do you think the purpose of this function is? How do you know?

  • What is the domain of rocket-height? Number

  • What is the range of rocket-height? How do you know? Number, we can tell by looking at the contract for the function.

  • As the program is currently written, what happens when I give the function an input of 5? 15? One million? It always returns 0.

Investigate

Let’s use the Design Recipe to fix rocket-height, and get comfortable with writing purpose statements.

Have students turn to Word Problem: rocket-height, read the problem statement with their partner and write down the Contract and purpose statement. Then, given the contract and purpose statement, write two examples of how rocket-height should work after two different lengths of time.

  • Circle and label what’s changing in the two examples, just as you did with the green triangle function before.

  • Choose a good variable name for what’s changing.

  • Write the function definition using the variable name.

Once the Design Recipe has been completed in the workbook, students can type the code into the rocket-height program, replacing any incorrect code with their own code.

Synthesize

  • What was the problem?

  • What mistake(s) did the programmer make?

  • Where in the Design Recipe did they first go astray?

The Design Recipe allows us to trace mistakes back to the source!

🔗More Interesting Functions flexible

Overview

For teachers who cover quadratic and exponential functions, this activity deepens students' understanding of functions and extends the Design Recipe to include those. This can also be a useful activity for students who finish early, or who need more of a challenge.

Launch

Now that rocket-height is working correctly, explore the rest of the file and try the following:

  • Remove the comment from before the (start rocket-height) and test the program.

  • Put the comment back in front of (start rocket-height), remove the comment from (graph rocket-height), and test the program.

  • Try out (space rocket-height)

  • Try out (everything rocket-height)

Investigate

  • Can you make the rocket fly faster? Slower?

  • Can you make the rocket sink down instead of fly up?

  • Can you make the rocket accelerate over time, so that it moves faster the longer it flies?

  • Can you make the rocket blast off and then land again?

  • Can you make the rocket blast off, reach a maximum height of exactly 1000 meters, and then land?

  • Can you make the rocket blast off, reach a maximum height of exactly 1000 meters, and then land after exactly 100 seconds?

  • Can you make the rocket fly to the edge of the the universe?

Synthesize

Debrief - what did students try? Have students share their experiments with one another!

The Design Recipe in your Classroom

The three steps of the Design Recipe are designed to mirror best practices that you may already be using in your classroom. The Design Recipe is merely a collection of those practices, assembled in a structured way.

Writing the Contract and Purpose Statement is where students understand the word problem. If you have your students restate the problem in their own words, draw pictures, or underline the inputs and outputs in the word problem, you’re already using this practice!

Writing examples and circles-and-and labeling what changes is where students apply their understanding. If you have your students work through some concrete examples before jumping straight to variables and formulas, and ask them "what’s the rule?" or "what’s the pattern?", you’re already using this practice!.

The order of the recipe is a recommendation based on years of research about what works for most students, but that doesn’t mean this order works best for every student! Some may find it easier to work through a concrete example or two before thinking about Domain and Range, and there’s nothing wrong with that. We encourage you to use the Recipe in your classroom as often as possible, teaching students to be flexible with the tools and representations it includes.

🔗Additional Exercises:

These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, and 1738598). CCbadge Bootstrap by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.