Boolean logic combines true and false into decisions.
AND, OR, and NOT let conditions express more than one requirement at a time.
A Boolean value is either true or false. Boolean logic uses the operators AND, OR, and NOT to combine conditions, producing one true/false result that a conditional can act on.
This topic is part of Big Idea 3: Algorithms and Programming. You will learn relational operators, the three logical operators, and how to read truth tables.
Why this matters: Real conditions often have several requirements, like "logged in AND verified." Boolean logic is how programs express those combinations.
AND needs both; OR needs one; NOT flips.
Three operators cover every combination.
Conditions are built from relational operators that compare values, such as <, >, and =. Each comparison gives a Boolean result. Logical operators then combine those results:
- AND is true only when both sides are true.
- OR is true when at least one side is true.
- NOT flips a Boolean: true becomes false, false becomes true.
A condition that combines operators is a compound condition. A truth table lists every combination of inputs and the result, which makes the behavior easy to verify.
Truth tables for AND, OR, and NOT showing every true/false combination.
Read each row as a set of inputs and their result. AND is true on only one row (both true); OR is false on only one row (both false); NOT simply reverses its input. On the exam, build a quick truth table when a compound condition is hard to reason about in your head.
The logic toolkit.
Know each operator precisely.
- Boolean: a value that is true or false.
- Relational operator: compares values, such as <, >, =.
- AND: true only when both conditions are true.
- OR: true when at least one condition is true.
- NOT: reverses a Boolean value.
- Compound condition: a condition combining operators.
Memory hook: AND is strict (both), OR is generous (either), NOT is the opposite switch.
How Boolean logic is tested.
Evaluating compound conditions is key.
Be ready to:
- Evaluate a compound condition for given true/false inputs.
- Tell AND and OR apart in tricky cases.
- Apply NOT to reverse a condition.
- Use a truth table to confirm a result.
Boolean logic is heavily tested because it underlies conditionals and loop conditions. Expect questions that ask whether a compound condition is true.
Exam tip: For AND, if either side is false, the whole thing is false. For OR, if either side is true, the whole thing is true. Check the quick-exit case first.
A login that needs both checks to pass.
Access requires a correct username AND password.
A login grants access only when the username is correct AND the password is correct. Here is the AP CSP pseudocode:
usernameCorrect ← true
passwordCorrect ← false
IF(usernameCorrect AND passwordCorrect)
{
DISPLAY("Access granted")
}
ELSE
{
DISPLAY("Access denied")
}
Evaluate the compound condition. With usernameCorrect = true and passwordCorrect = false, the AND is true only if both are true. Since one side is false, the whole condition is false.
So the ELSE branch runs and the program displays "Access denied". If the password were also true, both sides would be true, the AND would be true, and the program would display "Access granted." This is exactly why AND is the right operator here: a login should require both checks.
Logic errors to avoid.
These flip the meaning of a condition.
- Confusing AND with OR. AND needs both true; OR needs only one.
- Forgetting NOT reverses. NOT true is false, and NOT false is true.
- Misreading true/false results. Evaluate each side before combining.
- Using vague conditions. Conditions must be precise Boolean expressions.
- Treating Booleans as text. true and false are values, not the strings "true" and "false".
Reframe: AND is a strict gate that opens only when everything checks out. OR opens if any single check passes.
Boolean logic at a glance.
Operators and what makes them true.
| Term | Meaning | True when |
|---|---|---|
| Boolean | A true/false value | It is true |
| Relational operator | Compares two values | The comparison holds |
| AND | Combines two conditions | Both are true |
| OR | Combines two conditions | At least one is true |
| NOT | Reverses a condition | The original is false |
| Compound condition | Combines operators | The whole evaluates true |
Evaluate each side, then combine.
Break compound conditions into parts.
For any compound condition, first work out the true/false value of each side, then apply AND, OR, or NOT. Writing the small truth values above each part prevents mix-ups and is the safest way to handle the compound conditions that appear throughout the exam.
Try it: If a = true and b = true, what is NOT (a AND b)? Evaluate the inside first, then apply NOT.
Practice — attempt these now.
AP-style assessments aligned to this lesson. Time them.
AP CSP Big Idea 3 Topic 4: Boolean Logic — Set 1
AP-style topic practice assessment
AP CSP Big Idea 3 Topic 4: Boolean Logic — Set 2
AP-style topic practice assessment
AP CSP Big Idea 3 Topic 4: Boolean Logic — Set 3
AP-style topic practice assessment