Section 8.5
Logical Operators
Learning Goals
Students will write and evaluate expressions using relational operators (AAP-2.E)
Students will write and evaluate expressions using logical operators (AAP-2.F)
Students will determine use cases for compound Boolean expressions
AAP-2.E.1: A Boolean value is either true or false.
AAP-2.E.2: The exam reference sheet provides the following relational operators: =, ≠, >, <, ≥, and ≤.
● a = b
● a ≠ b
● a > b
● a < b
● a ≥ b
● a ≤ b
These are used to test the relationship between two variables, expressions, or values. A comparison using a relational operator evaluates to a Boolean value. For example, a = b evaluates to true if a and b are equal; otherwise, it evaluates to false.
AAP-2.F.1: The exam reference sheet provides the logical operators NOT, AND, and OR, which evaluate to a Boolean value.
AAP-2.F.2: The exam reference sheet provides the NOT condition, which evaluates to true if condition is false; otherwise it evaluates to false.
AAP-2.F.3: The exam reference sheet provides condition1 AND condition2, which evaluates to true if both condition1 and condition2 are true; otherwise it evaluates to false.
AAP-2.F.4: The exam reference sheet provides condition1 OR condition2, which evaluates to true if condition1 is true or if condition2 is true or if both condition1 and condition2 are true; otherwise it evaluates to false.
AAP-2.F.5: The operand for a logical operator is either a Boolean expression or a single Boolean value.
Objectives and Description
The objective of this lesson is to build upon the knowledge that students have of conditionals and relational operators by introducing them to logical operators. Using logical operators, they will be able to form compound boolean expressions so that they may apply conditionals to more complex scenarios. In this lesson’s activity, students will write a script that evaluates user input from related questions to produce a tailored music experience.
Activities
Activity 8.5.1 (40 minutes)
Navigate to AP Classroom and watch 3.5: Daily Video 1, "Boolean Expressions." Pause the video at 5:34 to allow the students to write a boolean expression to check if the average of grade1, grade2, and grade3 is at least 70. Finish the video and allow students to write and evaluate expressions that use relational operators.
Students will implement readInput() to ask the user a series of 2-3 questions when their script is run
Questions should be followed with a list of answer choices (recommend limiting to 2)
Each readInput() should be assigned to a variable so that the answer is stored
Students will use conditionals that evaluate compound boolean expressions to select appropriate sounds to play and add to their song
Refer to the example from the powerpoint slides
In addition to the sounds that are added to the song through the conditionals, encourage students to further flesh out their song (makeBeat(), additional song sections, etc.)
Resources
8.5.1: College Board's 3.5: Daily Video 1 titled, "Boolean Expressions" available through AP Central and AP Classroom (Student and Teacher resource)
8.5.1: Logical Operators Slide Deck (Student and Teacher Resource)