instagram

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
7.EE.B.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.

HSF.IF.A.2

Use function notation, evaluate functions for inputs in their domains, and interpret statements that use function notation in terms of a context.

Oklahoma Standards
OK.PA.A.4.3

Represent real-world situations using equations and inequalities involving one variable.

Lesson Goals

Students will be able to:

  • Describe how functions can work together.

  • Describe the solution set of a compound inequality

  • Make mathematical adjustments relevant to their game.

Student-Facing Lesson Goals

  • I can use two or more inequalities together and describe the area they enclose.

  • I can tell someone else how two or more functions work together.

  • I can make adjustments to a program based on how the program behaves.

Materials

Preparation

  • Make sure all materials have been gathered

  • Decide how students will be grouped in pairs

Supplemental Resources

Key Points for the Facilitator

  • Role-playing can help students understand the job of is-onscreen, and how it relates to is-safe-left and is-safe-right.

  • If a student’s TARGET and DANGER image seem to be "getting stuck" on the edge of the screen, the student may have to adjust the side Boundaaries depending on the size of their images.

  • The code for the Boundaary functions in the game is exactly the same as in Sam the Butterfly.

Click here to see the prior unit-based version

Glossary
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 produce true if both of their sub-expressions are true. Expresions using or produce true if either of their sub-expressions are true.

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? and onscreen?. 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 roleplaying onscreen should turn to safe-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 to is-safe-left, it’s not checking with is-safe-right

  • How can is-onscreen check with both?
    It needs to talk to is-safe-left AND is-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 and DANGER 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). CCbadge 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.