Standards in this Lesson |
|
Textbook Alignment |
|
Practices in this Lesson |
|
(Also available in Pyret)
Students take a closer look at how functions can work together by investigating the relationship between revenue, cost, and profit.
Lesson Goals |
Students will be able to:
|
Student-Facing Lesson Goals |
|
Materials |
|
Key Points for the Facilitator |
|
- function
-
a relation from a set of inputs to a set of possible outputs, where each input is related to exactly one output
🔗Problem Decomposition 30 minutes
Overview
Students are introduced to word problems that can be broken down into multiple problems, the solutions to which can be composed to solve other problems. They adapt the Design Recipe to handle this situation.
Launch
Display the following image:
Have students share everything they Notice about the image. Then, have them share what they Wonder.
-
One example of a relationship we can find in this situation is that every glass sold incurs costs. Sally will need lemons, sugar, powdered drink mix, cups, and water.
-
What other relationships can you find? Below are some possible observations students might share; it’s okay if students are not confident using terms such as cost, revenue, and profit!
-
Every glass sold brings in $1.75 in revenue.
-
Every glass sold brings in some amount of profit: it costs a certain amount to make, but it brings in another amount in revenue.
-
The total cost of the bike will be depend on the tax rate.
-
In order to figure out how many lemonade sales it will take to pay for the bike, we’d need to to divide the cost (with tax) by the profit per glass.
-
Investigate
-
Define functions for
revenue
andcost
on Revenue & Cost. Note: The information you need to write the cost function is provided in the Design Recipe word problem! -
Once you’ve defined the functions, open Sally’s Lemonade Starter File.
-
Enter your code for
revenue
(including all examples and definitions) below the first prompt. Enter your code forcost
below the second prompt. Click "Run" and make sure your tests pass. -
What is the difference between revenue and profit?
-
Revenue is the total amount of money that comes in, profit is the remaining money after cost has been subtracted.
-
-
How could Sally increase her profits?
-
By decreasing her costs, raising her prices (which increases revenue), by selling more lemonade.
-
-
What is the relationship between profit, cost, and revenue?
-
Profit = Revenue - Cost
-
Ensure that students have correctly defined the functions for revenue
and cost
before moving onto the next task - using the Design Recipe to define profit
.
-
Complete Word Problem: profit, using the Design Recipe. (There are multiple correct solutions!)
-
Add your code for
profit
in Sally’s Lemonade Starter File below the third prompt; be sure to type all examples and definitions. Click "Run". Do all your tests pass?
While students are working, walk the room and gauge student understanding. There is more than one way to write the profit
function! Encourage discussion between students and push them to develop their thinking on the advantages and disadvantages of each correct solution.
As students finish, or for homework, you may also want them to figure out how many cups of lemonade Sally would have to sell in order to buy her bike using Sally’s Bike.
Synthesize
This activity started with a situation, and students modeled that situation with functions. One part of the model was profit, which can be written several ways. Have students turn to Profit - More than one Way! and reflect on the four function definitions presented. Give them a few minutes.
The four definitions of profit
from this workbook page are shown here:
(define (profit g) (- (* 1.75 g) (* 0.30 g)))
(define (profit g) (* (- 1.75 0.30) g))
(define (profit g) (* 1.45 g))
(define (profit g) (- (revenue g) (cost g)))
-
Which of these four
profit
definitions do you think is "best", and why?-
Possible arguments: The first one is "closest to the word problem". The third one is "fastest", with the computation already completed. The last one is the most readable.
-
-
Did anyone have additional ideas for how to define a
profit
function? -
If lemons get more expensive, which definitions of
profit
need to be changed?-
Every definition except the last one would need to be changed.
-
-
If Sally raises her prices, which definitions of
profit
need to be changed?-
Every definition except the last one would need to be changed.
-
-
Which definition of
profit
is the most flexible? Why?-
The last definition is the most flexible; it can be used with any revenue and cost functions.
-
profit
can be decomposed into a simpler function that uses the cost
and revenue
functions.
Decomposing a problem allows us to solve it in smaller pieces
Big Ideas
-
Smaller pieces are easier to think about, and to test!
-
These pieces can also be re-used! Like lego pieces, smaller functions can be used to build all kinds of things.
-
Re-using code means less code overall. Less code means fewer places to make mistakes.
-
Re-using code means less duplicate code. When code needs to be changed, that change only needs to made in one place, instead of in multiple places.
🔗Top-Down vs. Bottom-Up 20 minutes
Overview
Students explore problem decomposition as an explicit strategy, and learn about two ways of decomposing.
Launch
Top-Down and Bottom-Up design are two different strategies for problem decomposition.
… | ||||||||
|
Bottom-Up: start with the small, easy relationships like revenue
and cost
first. How are they connected with the outer circle? You’ll get there eventually, but we can leave it blank for now (…
). In the Lemonade Stand, you defined cost
and revenue
first, and then put them together in profit
. This is the same approach as building your Circle of Evaluation inside-out!
- | ||
|
Top-Down: start with the "big picture" and then worry about the details later. We could have started with profit
as (- revenue cost)
, and fill in the details of revenue
and cost
later (thus the …
). This is the same approach as building your Circle of Evaluation outside-in!
Investigate
Consider the following situation:
Jamal’s trip requires him to drive 20mi to the airport, fly 2300mi, and then take a bus 6mi to his hotel. His average speed driving to the airport is 40mph, the average speed of an airplane is 575mph, and the average speed of his bus is 15mph. Aside from time waiting for the plane or bus, how long is Jamal in transit?
Take a moment to think: What would your first step be if you were trying to figure out how long Jamal would be transit? What circles would you draw or functions would you define to solve this? Would you work top-down or bottom-up?
Then turn to Top Down or Bottom Up.
Synthesize
Make sure that students see both strategies, and have them discuss which they prefer and why.
-
Whose strategy was top-down? How do you know?
-
Do you have questions about either of these strategies?
-
Which strategy to do you prefer? Why?
These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, and 1738598). 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.