Boolean Expressions

Ben Davis
6 min read
Listen to this study note
Study Guide Overview
This study guide covers Boolean logic for the AP Computer Science Principles exam. It focuses on Boolean variables, relational operators (==
, !=
, >
, <
, >=
, <=
), logical operators (NOT
, AND
, OR
), and truth tables. It also explains common mistakes, operator precedence, and provides practice questions involving conditional statements and combining Boolean logic with other programming concepts.
#AP Computer Science Principles: Boolean Logic - The Night Before
Hey! Let's get you prepped for the exam. We're going to break down Boolean logic, which is super important for both multiple-choice and free-response questions. Think of this as your quick-scan guide for tonight. Let's dive in!
#Boolean Variables and Relational Operators
#What are Boolean Variables?
Boolean variables are like light switches: they're either true or false. That's it! No in-between. They are fundamental for decision-making in code.
Boolean values are the backbone of conditional statements and loops. Understanding them is crucial for controlling the flow of your programs.
#Relational Operators
These are the tools we use to create Boolean values. They compare two values and return either true
or false
based on the relationship. Here’s a quick rundown:
Operator | Meaning | Example | Result (if x=10, y=5) |
---|---|---|---|
== | Equal to | x == y | false |
!= | Not equal to | x != y | true |
> | Greater than | x > y | true |
< | Less than | x < y | false |
>= | Greater than or equal to | x >= y | true |
<= | Less than or equal to | x <= y | false |

How are we doing?
Give us your feedback and let us know how we can improve