Students learn to compose inequalities using the concepts of union and intersection, and solve problems using compound inequalities. Finally, they apply what they’ve learned to set screen boundaries in their game.
Prerequisites |
|
Relevant Standards |
Select one or more standards from the menu on the left (⌘-click on Mac, Ctrl-click elsewhere). Common Core Math Standards
Oklahoma Standards
|
Lesson Goals |
Students will be able to:
|
Student-Facing Lesson Goals |
|
Materials |
|
Preparation |
|
Supplemental Resources |
|
Key Points for the Facilitator |
|
Click here to see the prior unit-based version
- coordinate
-
a number or set of numbers describing an object’s location
- function
-
a mathematical object that consumes inputs and produces an output
🔗Compound Inequalities 10 minutes
Overview
Students consider the need to compose inequalities, and think about how to write them.
Launch
Students should have their computer, contracts page, and pencil and be logged in to code.pyret.org with their Game Project file open.
We use inequalities for lots of things:
-
Is it hot out? (temperature > 80°)
-
Did I get paid enough for painting that fence? (temperature < $100)
-
Are the cookies finished baking? (timer = 0)
Have students come up with other examples.
But many times we need to combine inequalities:
-
Should I go to the beach? (temperature > 80° and weather = "sunny")
-
Was this burrito worth the price? (taste = "delicious" and price ≤ $20)
Have students come up with other examples.
Guide students through other examples of and
and or
with various statements, such as "I’m wearing a red shirt AND I’m a math teacher, true or false?" or "I’m an NBA basketball star OR I’m having pizza for lunch, true or false?". This can make for a good sit-down, stand-up activity, where students take turns saying compound boolean statements and everyone stands if that statement is true for them.
Investigate
Both mathematics and programming have ways of combining - or composing - inequalities.
Have students complete Inequalities — Practice (Page 45).
Synthesize
-
Be really careful to check for understanding here. Expresions using
and
only producetrue
if both of their sub-expressions aretrue
. Expresions usingor
producetrue
if either of their sub-expressions aretrue
.
Strategies for English Language Learners When describing compound inequalities, be careful not to use "english shortcuts". For example, we might say "I am holding a marker and an eraser" instead of "I am holding a marker and I am holding an eraser." These sentences mean the same thing, but the first one obscures the fact that "and" joins two complete phrases. For ELL/ESL students, this is unecessarily adds to cognitive load! |
🔗Protecting Sam on Both Sides 30 minutes
Overview
Students solve a word problem involving compound inequalities, using and
to compose the simpler Boundary-checking functions from the previous lesson.
Launch
-
Recruit three student volunteers to roleplay the functions
safe-left?
,safe-right?
andonscreen?
. Give them 1 minute to read the contract and code, as written in the program. -
As in the previous lesson, ask the volunteers what their name, Domain and Range are, and then test them out by calling out their name, followed by a number. (For example, "(safe-left? 20)!", "(safe-right? -100)!", "(onscreen? 829)!") Note" the code for
onscreen
calls the safe-left function!. So the student roleplayingonscreen
should turn tosafe-left
and give the input to them.
For example:
-
Facilitator: "is-onscreen 70"
-
is-onscreen (turns to is-safe-left): "is-safe-left 70"
-
is-safe-left: "true"
-
is-onscreen (turns back to facilitator): "true"
-
Facilitator: "onscreen-huh -100"
-
is-onscreen (turns to is-safe-left): "safe-left-huh -100"
-
is-safe-left: "false"
-
is-onscreen (turns back to facilitator): "false"
-
Facilitator: "onscreen-huh 900"
-
is-onscreen (turns to is-safe-left): "safe-left-huh 900"
-
is-safe-left: "true"
-
is-onscreen (turns back to facilitator): "true"
Ask the rest of the class
-
What is the problem with
is-onscreen
?
It’s only talking tois-safe-left
, it’s not checking withis-safe-right
-
How can
is-onscreen
check with both?
It needs to talk tois-safe-left
ANDis-safe-right
Have students complete Word Problem: is-onscreen (Page 46). When this functions is entered into WeScheme, students should now see that Sam is protected on _both sides of the screen.
Extension Option What if we wanted to keep Sam safe on the top and bottom edges of the screen as well? What additional functions would we need? What functions would need to change? |
🔗Boundary Detection in the Game 10 minutes
Overview
Students identify common patterns between 2-dimensional Boundaary detection and detecting whether a player is onscreen. They apply the same problem-solving and narrow mathematical concept from the previous lesson to a more general problem.
Launch
Have students open their in-progress game file and press Run.
-
How are the
TARGET
andDANGER
behaving right now?
They move across the screen. -
What do we want to change?
We want them to come back after they leave one side of the screen. -
How do we know when an image has moved off the screen?
We can see it. -
How can we make the computer understand when an image has moved off the screen?
We can teach the computer to compare the image’s coordinates to a numeric Boundaary, just like we did with Sam the Butterfly!
Investigate
Students apply what they learned from Sam the Butterly to fix the is-safe-left
, is-safe-right
, and is-onscreen
functions in their own code.
Since the screen dimensions for their game are 640x480, just like Sam, they can use their code from Sam as a starting point.
Common Misconceptions
-
Students will need to test their code with their images to see if the Boundaaries are correct for them. Students with large images may need to use slightly wider Boundaaries, or vice versa for small images. In some cases, students may have to go back and rescale their images if they are too large or too small for the game.
-
Students may be surprised that the same code that "traps Sam" also "resets the
DANGER
and `TARGET`". It’s critical to explain that these functions do neither of those things! All they do is test if a coordinate is within a certain range on the x-axis. There is other code (hidden in the teachpack) that determines what to do if the coordinate is offscreen. The ability to re-use function is one of the most powerful features of mathematics - and programming!
🔗Additional Exercises:
These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, and 1738598). Bootstrap:Algebra by Emmanuel Schanzer, Jen Poole, Ed Campos Jr, Flannery Denny, and Dorai Sitaram is licensed under a Creative Commons 4.0 Unported License. Based on a work at www.BootstrapWorld.org. Permissions beyond the scope of this license may be available by contacting schanzer@BootstrapWorld.org.