Section 8.5

Logical Operators

Learning Goals

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)

Resources