Please enable JavaScript to use CodeHS

AP Computer Science A (Mocha)

Lesson 2.7 Logical Operators

Description

Logical operators allow us to connect or modify Boolean expressions. Three logical operators are the !, ||, && characters.
! = NOT
|| = OR
&& = AND
Logical operators can be used in combination.

With these logical operators, we can construct logical statements such as “I go to sleep when I am tired OR it’s after 9pm”, “I wear flip flops when I am outside AND it is NOT raining”


Objective

Students will be able to…
* Describe the meaning and usage of each logical operator: OR (||), AND (&&), and NOT (!)
* Construct logical statements using boolean variables and logical operators