Lesson 10: Booleans Unplugged
In this lesson, students are introduced to boolean values and logic, as well as conditional statements. The class starts by playing a simple game of Stand Up, Sit Down in which the boolean (true/false) statements describe personal properties (hair or eye color, clothing type, age, etc). This gets students thinking about how they can frame a property with multiple potential values (such as age) with a binary question.
From there students are provided a group of objects with similar, yet varying, physical properties. With a partner they group those objects based on increasingly complex boolean statements, including compound booleans with AND and OR.
Finally we reveal Conditionals as a tool to make decisions or impact the flow of a program using boolean statements as input.
Warm Up (10 min)
Activity (30 min)
Wrap Up (5 min)
Students will be able to:
- Organize objects based on simple and compound boolean statements
- Describe the properties of an object using boolean statements
- Read the Forum
- Print a copy of the Boolean Properties - Activity Guide for each student
- (Optional) Gather objects with similar but varying features to use instead of the worksheet (LEGO bricks work well, a mixed bag of candy can be fun as well)
For the Students
- Boolean Properties - Activity Guide
- Boolean - A single value of either TRUE or FALSE
- Conditionals - Statements that only run under certain conditions.
- Expression - Any valid unit of code that resolves to a value.
Warm Up (10 min)
Stand Up, Sit Down
Distribute: 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:
For Each Card:
- Select a card
- Say: I’m going to read the answer to #8 but if it is you, don’t say anything.
- Read the answer to #8
- Say: Now everyone stand up and we are going to ask some questions with Boolean answers to help determine who this person is. I'm going to say a bunch of statements. If they are true about you stay standing. If they are false sit down.
- Translate the answers from #1 to #7 into statements that can either be true or false (See below). The person whose card it is should always answer true.
- 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 purple”.
|1) What is your hair color?||brown||"My hair color is brown."|
|2) Do you wear glasses or contacts?||yes||"I wear glasses or contacts."|
|3) What is your favorite number?||12||"My favorite number is greater than 10 and less than 20."|
|4) What is your favorite color?||purple||"My favorite color appears in a sunset."|
|5) What month were you born||May||"I was born in the spring."|
|6) Do you have any siblings?||yes||"I have siblings."|
|7) What is the last digit of your phone number?||5||"The last digit of my phone number is prime."|
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, “I was born in May OR my favorite number is 12” is true. Note that “I was born in May OR my favorite number is 13” is also true.
Play this several times changing the true/false statements you use. Be creative with using or and and. Remind students that the OR means that either part of the statement being true will result in the entire statement being true.
Discuss: the Stand up Sit Down game with students:
- What kinds of questions did the teacher ask?
- Were you ever confused about whether you should be standing or sitting? Why?
- At any point in the game, how many different states could you be in?
Introduce the vocabulary boolean as a description for the kinds of questions we were asking. The defining feature of a Boolean is that it can have only two states - in our game those states were True and False, or Standing and Sitting
Activity (30 min)
Asking the Right Questions
Prompt: Brainstorm places where they've seen Boolean values before, either in the class or in the world.
Discuss: Have students share out their answers. Potential answers could include:
- Flow charts
- Light switches (and other devices that can be on or off)
Sorting with Booleans
In the game we played, the boolean questions I asked were all based on your properties. Your properties didn't have to exist in only two states (how many different hair colors are in the room?), but the questions I asked had to split them into two states (how many people in the room have red hair?). We're going to do similar sorting using the properties of various images.
Students often struggle with the idea of greater-than or equals to ever being FALSE - they tend to think of those as statements of truth rather than questions of relation.
In this activity we use the language something is equal to something else in order to mirror the code they'll see later (eg
something == something_else), but for students who are struggling with seeing this as a question rather than a statement, you can encourage them to reword the statement by moving the 'is' to the beginning, so:
something is equal to something else
is something equal to something else?
When combining booleans with OR we are using what is called a logical or - meaning that we are asking if either (or both) or the booleans is TRUE. Students often default to thinking of OR as an exclusive or - meaning that we are asking if only one (but not the other) is TRUE.
Make sure you ask students questions or questions where both of the booleans are TRUE to ensure you can get at this misconception early
Group: Organize students into pairs
Set Up: Assign each member of the pair as either True or False.
Distribute: Hand out the cut out the images from the worksheet, or provide students with some objects to sort (such as LEGO bricks or candies).
I'm going to read a bunch of binary statements in the form of
shape is equal to square or
sides is greater than 4, and you are going to sort through their objects to organize them into TRUE and FALSE piles. If students disagree about which pile an object should go into they should first discuss what the property is, what the two outcomes of the binary question are, and then if they still cannot agree they should bring it to the class for a vote.
If you are using the provided cutouts, you can start with the following questions:
- sides is equal to 3
- fill is equal to black
- corners is less than 1
- width is equal to height
- fill is equal to grey AND sides is greater than 4
- sides is greater than 4 AND less than 7
- sides is greater than 4 OR less than 7
- sides is NOT less than 5
Goal: After getting used to sorting objects into TRUE and FALSE, we need to introduce students to the concept that Booleans can also be used to control the flow of a program.
A conditional allows us to make a decision based on the outcome of a boolean question (or condition). We actually were implicitly using conditionals in the Stand Up, Sit Down activity because there was an action related to each potential outcome of the boolean. We could have rephrased the instructions as
if statement is true: remain standing else: sit down
Prompt: Select one object from your pile and hold it up.
I'm going to ask you a boolean question about your object and give you an action related to the potentail outcome of the boolean. Figure out what your response should be for your shape and do the correct response.
Prompt: Ask students some boolean questions about that single object AND give students something to do if that question is true. For example:
- If sides is equal to 4, do a dance
- If pattern is equal to striped, sit down
- If width is equal to height, hop on one foot
Wrap Up (5 min)
Goal: Booleans and conditionals are actually something that we use in our everyday lives - we just aren't usually explicit about it.
Model: As a way to practice thinking explicitly about conditionals, consider dismissing your students using compound booleans and conditionals. For example.
- If you sit at table four and your hair is brown, you may leave.
- If your first name starts with A OR B, you may leave.
- If your shoes are black, you may leave.
CSTA K-12 Computer Science Standards (2017)
AP - Algorithms & Programming
- 2-AP-10 - Use flowcharts and/or pseudocode to address complex problems as algorithms.