# Teachers Toolkit: Boolean Expressions

### Mouse in the Maze

Word problems that use "and" and "or" can be confusing. In fact, sometimes the English we use is not the way we write the program. For instance a restaurant may say "We give a discount to children and seniors." But the program is testing one individual case and uses child OR senior. I often use this example to make the students aware of the language. I can use the mouse in the maze to present many examples in the time it takes to explain one word problem.

Doors in the maze are represented by Boolean variable. True means the door is open, false if it is closed. Write the Boolean expression for when the mouse can escape.

### A Nice Day

When I teach if/else I usually have a conversation like the one below:
Me: Is today a nice day?
Student: Yes.
Me: What makes it a nice day?
Student: It not cold.
Me: What temperature does it need to be to be a nice day?
Student: 50
Me: Exactly 50?
Student: At least 50.
Me: How do we say "at least 50" in C++?
Student: temperature>=50
Me: Good. Is that it? If it is greater than or equal to 50 then it's a nice day?
Student: It can't be raining.
Another student: And it can't be windy!
Then we write the program. It doesn't always go as planned. I did that recently and the student answered, "Anything is better than yesterday."  Another student objected to the 50 degrees She said, "No, I'm sick of the cold! It has to be at least 80!"

### A Donut

Child: Mommy, can I have a donut?
Mother:OK
Child: Can I have a soda?
Mother: You can have a donut and a glass of milk, or soda.
Child: OK! A donut and a glass of milk or soda.

I ask the students, where did the mother put the parentheses? Where did the child put the parentheses?

### Everybody stand up!

I was doing the letter grade from average using a nested if else. I had written
One student couldn't understand why I didn't need to say that the average was also >=65.

Finally I said, "OK, Everybody stand up!"
I asked all of the women to sit.
They said "Just the guys."
Then I said, OK, I want the married men to sit.
Can I just say "If you are married sit down." or do I need to say "Married men should sit."
I continued the game, asking different groups to sit. (wearing glasses, take the bus, etc.)
Each time I asked, "Who's still standing?"

This web site, and all pages therein, are the sole property and responsibility of Zebra0.com.
It is not endorsed, sponsored or provided by or on behalf of Montgomery College.