Lesson 5: Boolean Operators
Overview
Using Boolean operators, students will write code that compares values to make logical decisions.
Agenda
Getting Started
Activity
View on Code Studio
Anchor Standards
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.
Objectives
Students will be able to:
- Use Boolean operators to compare values.
- Apply Boolean logic, such as AND, OR, and NOT, to compose complex Boolean comparisons.
Support
Report a Bug
Teaching Guide
Getting Started
Introduction
Creating some sample boolean expressions - both simple and complex - is an excellent warm-up activity before the puzzle stages. Some examples have been included in the slide deck. The slide deck also has extra practice related to expressions that the students will have seen in the puzzles.
Student Instructions
Boolean operators (like >, <, =) allow us to compare different values, returning either true or false. Click "Run" to see how this expression evaluates.
Student Instructions
Can you set the values so that this expression evaluates as true?
Student Instructions
The string-length
function returns the number of characters in a string (including spaces!) - make this code evaluate to true.
Student Instructions
Here's an Evaluation Block called and
- it returns true if both of its parameters are true, otherwise it returns false. Edit the x variable so that this expression returns true.
Student Instructions
This or
block returns true if either of its parameters is true. Otherwise, if both parameters are false it will return false. Set the y variable to a value that will cause this expression to return false.
Student Instructions
Here's one more boolean block called not
. This block flips true to false, or false to true. If you wrap this block of code in a NOT block, it should return true (because we are asking if the two expressions do NOT produce equal values).
Student Instructions
Student Instructions
Student Instructions
Student Instructions
Free Play: Try out some creations of your own using Booleans.
Standards Alignment
View full course alignment
Common Core Math Standards
EE - Expressions And Equations
- 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 va
- 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.
F - Functions
- 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
MP - 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
NS - The Number System
- 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.
OA - Operations And Algebraic Thinking
- 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 t
Q - Quantities
- N.Q.1 - Use units as a way to understand problems and to guide the solution of multi-step problems; choose and interpret units consistently in formulas; choose and interpret the scale and the origin in graphs and data displays.
- N.Q.2 - Define appropriate quantities for the purpose of descriptive modeling.