Lesson 10: Booleans Unplugged

Overview

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.

Agenda

Warm Up (10 min)

Activity (30 min)

Wrap Up (5 min)

View on Code Studio

Objectives

Students will be able to:

  • Organize objects based on simple and compound boolean statements
  • Describe the properties of an object using boolean statements

Preparation

  • 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)

Links

Heads Up! Please make a copy of any documents you plan to share with students.

For the Students

Vocabulary

  • Boolean - A single value of either TRUE or FALSE
  • Conditionals - Statements that only run when certain conditions are true.
  • Expression - Any valid unit of code that resolves to a value.

Teaching Guide

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)

  1. What is your hair color?
  2. Do you wear glasses or contacts?
  3. What is your favorite number?
  4. What is your favorite color?
  5. What month were you born?
  6. Do you have any siblings?
  7. What is the last digit of your phone number?
  8. 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:

  1. Select a card
  2. Say: I’m going to read the answer to #8 but if it is you, don’t say anything.
  3. Read the answer to #8
  4. 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.
  5. 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.
  6. 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”.

Example Translation

Question Answer True/False Statement
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."

Content Corner

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

Brainstorm

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:

  • Binary
  • Flow charts
  • Light switches (and other devices that can be on or off)

Sorting with Booleans

Remarks

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.

Teaching Tip

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

becomes

is something equal to something else?

Content Corner

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).

Remarks

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

Conditionals

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.

Remarks

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.

Remarks

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)

Explicit Conditionals

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.

Standards Alignment

View full course alignment

CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
  • 2-AP-10 - Use flowcharts and/or pseudocode to address complex problems as algorithms.