Booleans are the fourth and final data type that students will learn about in this course. In this stage, students will learn about Boolean (true/false) values, and explore how they can be used to evaluate logical questions.
Evaluate simple Boolean expressions.
Evaluate complex Boolean expressions.
Common Core Math Standards
- 7.EE.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.
Additional standards alignment can be found at the end of this lesson
Activity: Booleans 20 Questions
Materials, Resources, and Prep
For the Teacher
For the Students
- 3 x 5 cards, pens or pencils
This lesson has two new and important words:
- Boolean - a type of data with two values: true and false.
- Return - used as a synonym for output of a function.
What types of data have we used in our programs so far?
- Can you think of Number values?
- String values? Image values?
- What are some expressions that evaluate to a Number?
- How about the other datatypes?
What would each of the following expressions evaluate to?
The last expression, (3 < 4), uses a new function that compares Numbers, returning true if 3 is less than 4. What do you think it would return if the numbers were swapped?
The function < tests if one number is less than another. Can you think of some other tests?
Functions like <, > and = all consume two Numbers as their Domain, and produce a special value called a Boolean as their Range. Booleans are answers to a yes-or-no question, and Boolean functions are used to perform tests. In a videogame, you might test if a player has walked into a wall, or if their health is equal to zero. A machine in a doctor’s office might use Booleans to test if a patient’s heart rate is above or below a certain level.
Boolean values can only be true or false.
Give each student a card and have them answer the following questions on it (feel free to add some of your own)
- What is your hair color?
- Do you wear glasses or contacts?
- What is your favorite number?
- What is your favorite color?
- What month were you born?
- Do you have any siblings?
- What is the last digit of your phone number?
- What is something about you that people here don't know and can't tell by looking at you?
Then collect the cards and shuffle them. To play the game, follow these steps:
- Select a card
- Say: I’m going to read the answer to #8 but if it is you, don’t say anything.
- Say: Now everyone stand up and we are going to ask some questions with Boolean answers to help determine who this person is.
- Begin the following true/false questions. Preface each one with “If you answer false to the following question, please sit down.” The person whose card you are reading should always answer true so you will need to change the example questions below. For this example, the answers were:
- What is your hair color? - brown
- Do you wear glasses or contacts? - yes
- What is your favorite number? - 13
- What is your favorite color? - blue
- What month were you born? - December
- Do you have any siblings? - yes
- What is the last digit of your phone number? - 7
With that example, you might make the following statements:
- My hair color is brown.
- I wear contacts or glasses. (you only have to answer true to One of these to remain standing)
- My favorite number is greater than 10 and less than 20. (you must answer true to both these.)
- My favorite color is blue or green.
- I was not born in April.
- I have at least one sibling.
- The last digit of my phone number is a prime number.
Because of how numbers 3,4, 5, and 7 were asked it is likely that some people will still be standing. You will need to revisit these and ask them again in a more narrow fashion such as “My favorite color is blue”.
Play this several times. Be creative with using ors and ands. Remind students that the OR means that either part of the statement being true will result in the entire statement being true. In English, an “or” is often an “exclusive or” such as “You can have chicken or fish.” In English, you only get to pick one, but with Boolean logic you could have chicken, fish, or both!! For the example person above, “I was born in December OR my favorite number is 13” is true. Note that “I was born in December AND my favorite number is 13” is also true.
Have a student try to act as the quizmaster after several rounds. If a mistake is made by you, a student quizmaster, or the person whose card you are reading, see if you can analyze where the mistake was made or why the question being asked might not have been clear.
How does this activity connect with our game? In our game, we may need to determine: Is a target too far left or too far right? If so, then perhaps some action should occur.
Common Core Math Standards
- 5.OA.1 - Use parentheses, brackets, or braces in numerical expressions, and evaluate expressions with these symbols.
- 5.OA.2 - Write simple expressions that record calculations with numbers, and interpret numerical expressions without evaluating them. For example, express the calculation “add 8 and 7, then multiply by 2” as 2 × (8 + 7). Recognize that 3 × (18932 + 921) is three times as large as 18932 + 921, without having to calculate the indicated sum or product.
- 6.NS.8 - Solve real-world and mathematical problems by graphing points in all four quadrants of the coordinate plane. Include use of coordinates and absolute value to find distances between points with the same first coordinate or the same second coordinate.
- 6.EE.9 - Use variables to represent two quantities in a real-world problem that change in relationship to one another; write an equation to express one quantity, thought of as the dependent variable, in terms of the other quantity, thought of as the independent variable. Analyze the relationship between the dependent and independent variables using graphs and tables, and relate these to the equation. For example, in a problem involving motion at constant speed, list and graph ordered pairs of distances and times, and write the equation d = 65t to represent the relationship between distance and time.
- 7.EE.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.
- 8.F.1 - Understand that a function is a rule that assigns to each input exactly one output. The graph of a function is the set of ordered pairs consisting of an input and the corresponding output.1
- 8.F.2 - Compare properties of two functions each represented in a different way (algebraically, graphically, numerically in tables, or by verbal descriptions). For example, given a linear function represented by a table of values and a linear function represented by an algebraic expression, determine which function has the greater rate of change.
- A.REI.3 - Solve linear equations and inequalities in one variable, including equations with coefficients represented by letters.
- A.REI.10 - Understand that the graph of an equation in two variables is the set of all its solutions plotted in the coordinate plane, often forming a curve (which could be a line).
Common Core Math Practices
- MP.1 - Make sense of problems and persevere in solving them.
- MP.2 - Reason abstractly and quantitatively.
- MP.3 - Construct viable arguments and critique the reasoning of others.
- MP.4 - Model with mathematics.
- MP.5 - Use appropriate tools strategically.
- MP.6 - Attend to precision.
- MP.7 - Look for and make use of structure.
- MP.8 - Look for and express regularity in repeated reasoning.