(Also available in WeScheme)
Students build upon their understanding of booleans and simple inequalities to compose compound inequalities using the concepts of union and intersection.
Lesson Goals 
Students will be able to:

StudentFacing Lesson Goals 

Materials 

Preparation 

 function

a mathematical object that consumes inputs and produces an output
 intersection

the set of values that makes both inequalities true
 union

the set of values that makes either or both of a set of inequalities true
🔗Introducing Compound Inequalities
Overview
Students consider the need to compose inequalities, and think about how to write them.
Launch
We use inequalities for lots of things:

Is it hot out? (temperature > 80°)

Did I get paid enough for painting that fence? (paid \ge $100)

Are the cookies finished baking? (timer = 0)
Have students come up with other examples.
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 ≤ $15)
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 sitdown, standup 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.
Synthesize
Be really careful to check for understanding here.

Expressions using
and
only producetrue
if both of their subexpressions aretrue
. 
Expressions using
or
producetrue
if either of their subexpressions 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! 
🔗Solutions and NonSolutions of Compound Inequalities
Launch
Have students identify 4 solutions and 4 nonsolutions for each of the following inequalities.

x > 5

x \le 15
What about the solution set of x > 5 and
x \le 15? What numbers make both of these inequality expressions true?
How would that be different from x > 5 or
x \le 15? What numbers make at least one of these inequality expressions true?
Investigate
Have students log in to the Compound Inequalities Starter File (Pyret), read the code carefully and click run to see the graphs they’ve just considered.
This starter file includes two special functions.
andintersection
takes in two functions and a list of numbers and produces a graph with the points and the shaded intersection of values that make both of the inequalities true.
fun gt5(x): x > 5 end
fun lte15(x): x <= 15 end
andintersection(gt5, lte15, [list: 5, 2.1, 0, 5, 10, 39/5, 15, 20])
fun lt5(x): x < 5 end
fun gte15(x): x >= 15 end
andintersection(lt5, gte15, [list: 5, 2.1, 0, 5, 10, 39/5, 15, 20])
Note: Some pairs of inequalities do not intersect at all and therefore have no solutions.
orunion
takes in two functions and a list of numbers and produces a graph with the points and the shaded union of values that make either or both of the inequalities true.
fun lt5(x): x < 5 end
fun gte15(x): x >= 15 end
orunion(lt5, gte15, [list: 5, 2.1, 0, 5, 10, 39/5, 15, 20])
fun gt5(x): x > 5 end
fun lte15(x): x <= 15 end
orunion(gt5, lte15, [list: 5, 2.1, 0, 5, 10, 39/5, 15, 20])
Note: Some unions, like the one below, include all real numbers; they have have infinite solutions that satisfy at least one of the inequalities.
Turn to Compound Inequalities: Solutions & NonSolutions and explore the compound inequalities listed using the Compound Inequalities Starter File , identifying solutions and nonsolutions for each.
Instead of defining two functions as simple inequalities, we could produce the same graph by defining one function to be a compound inequality.
fun fiveto15(x): (x > 5) and (x <= 15) end inequality(fiveto15, [list: 5, 2.1, 0, 5, 10, 12, 15, 20])
Turn to Compound Inequality Functions and have students write code to describe the compound inequalities pictured.
If you have time, have students open to Matching Compound Inequality Functions and plots (Desmos)
Synthesize

How did the graphs of intersections and unions differ?
🔗Additional Exercises:
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.