AP CSP Boolean Expressions

AP CSP Topics › Boolean Expressions

AP CSP Boolean Expressions AND / OR / NOT: Complete Guide (2025‑2026)

Boolean expressions evaluate to either TRUE or FALSE. AP pseudocode uses three logical operators: AND (both must be true), OR (at least one must be true), and NOT (flips the value). Boolean expressions are the engine behind every conditional and loop — and a top-tested concept on the AP CSP exam, especially in the I/II/III question format.

3Logical operators in AP pseudocode: AND, OR, NOT
1Case where AND is TRUE: only when BOTH operands are TRUE
1Case where OR is FALSE: only when BOTH operands are FALSE

Truth Tables

Memorize these three patterns. The AP exam will present a boolean expression and ask you to evaluate it for specific values of the variables.

Truth Tables: AND, OR, NOT AND Both must be TRUE A B A AND B TTT TFF FTF FFF TRUE only when BOTH are TRUE OR At least one must be TRUE A B A OR B TTT TFT FTT FFF FALSE only when BOTH are FALSE NOT Flips TRUE to FALSE A NOT A TRUEFALSE FALSETRUE Reverses the boolean value

AND is strict (both must be TRUE). OR is lenient (either is enough). NOT flips. These three combine to form any logical condition.

Compound Expressions

Evaluating Compound AND
All parts must be TRUE
  • x > 0 AND x < 10
  • x=5: TRUE AND TRUE = TRUE
  • x=0: FALSE AND TRUE = FALSE
  • x=15: TRUE AND FALSE = FALSE
  • Short-circuit: if first is FALSE, result is FALSE
Evaluating Compound OR
Any part being TRUE is enough
  • score < 60 OR score > 100
  • score=50: TRUE OR FALSE = TRUE
  • score=80: FALSE OR FALSE = FALSE
  • score=110: FALSE OR TRUE = TRUE
  • Short-circuit: if first is TRUE, result is TRUE

Code Trace Gauntlet

Substitute values into the boolean expression before revealing. This exact skill appears on every AP CSP exam.

Trace 1 — Evaluate with Specific Values
x 7 y 3 DISPLAY(x > 5 AND y < 10) DISPLAY(x < 5 OR y < 10) DISPLAY(NOT (x = 7))

What does each DISPLAY output?

Output

TRUE TRUE FALSE Line 3: (7>5)=TRUE AND (3<10)=TRUE → TRUE AND TRUE = TRUE Line 4: (7<5)=FALSE OR (3<10)=TRUE → FALSE OR TRUE = TRUE Line 5: NOT(7=7) = NOT(TRUE) = FALSE

Trace 2 — Compound with NOT
a TRUE b FALSE DISPLAY(a AND NOT b) DISPLAY(NOT a OR b) DISPLAY(NOT (a AND b))

Predict all three outputs before revealing.

Output

TRUE FALSE TRUE Line 3: a=TRUE, NOT b = NOT FALSE = TRUE. TRUE AND TRUE = TRUE Line 4: NOT a = FALSE. FALSE OR b = FALSE OR FALSE = FALSE Line 5: a AND b = TRUE AND FALSE = FALSE. NOT FALSE = TRUE

Trace 3 — Range Check
grade 85 isB (grade 80) AND (grade < 90) DISPLAY(isB)

Does grade 85 fall in the B range (80-89)?

Output

TRUE (85 ≥ 80) = TRUE and (85 < 90) = TRUE. TRUE AND TRUE = TRUE. Grade 85 is in the B range.

Trace 4 — Nested NOT
p FALSE q TRUE DISPLAY(NOT (NOT p AND q))

Evaluate inside-out. What displays?

Output

FALSE NOT p = NOT FALSE = TRUE. TRUE AND q = TRUE AND TRUE = TRUE. NOT(TRUE) = FALSE.

Spot the Bug

SPOT THE BUG — Wrong Operator for Exclusion
# Intended: reject scores below 0 OR above 100 IF (score < 0 AND score > 100) DISPLAY(“invalid”)
Bug Explained

No score can be simultaneously less than 0 AND greater than 100. The AND makes this condition impossible — it will never trigger. Fix: change AND to OR. A score below 0 OR above 100 is invalid.

SPOT THE BUG — De Morgan’s Law Violation
# Intended: not (both conditions true) DISPLAY(NOT a AND NOT b)
Bug Explained

NOT a AND NOT b means ‘neither a nor b’. NOT(a AND b) means ‘not both’ (at least one is false). These are different. De Morgan’s Law: NOT(a AND b) = NOT a OR NOT b. To negate a compound, flip AND/OR and negate each operand.

Common Exam Pitfalls

1
Thinking OR requires both to be true

OR is TRUE when at least one operand is TRUE. Only AND requires both. This is the #1 boolean error on the AP exam.

2
Misapplying NOT to compound expressions

NOT(a AND b) is NOT the same as NOT a AND NOT b. Apply De Morgan’s Law: NOT(a AND b) = NOT a OR NOT b. NOT(a OR b) = NOT a AND NOT b.

3
Evaluating = as assignment inside a condition

In AP pseudocode, = inside a condition means equality comparison (not assignment). x = 5 in a boolean context asks ‘does x equal 5?’

4
Missing impossible compound conditions

A value cannot be both <0 AND >100 simultaneously. Always check whether your AND condition is satisfiable. If not, you likely need OR.

Check for Understanding

1. If x = 4 and y = 8, what is the value of (x > 3) AND (y < 6)?

  • TRUE
  • FALSE
  • 4
  • ERROR
(x>3) = (4>3) = TRUE. (y<6) = (8<6) = FALSE. TRUE AND FALSE = FALSE.

2. If a = TRUE and b = FALSE, which expression evaluates to TRUE?

  • a AND b
  • NOT a AND b
  • NOT a OR b
  • a OR NOT b
a OR NOT b = TRUE OR (NOT FALSE) = TRUE OR TRUE = TRUE. The others: AND b forces FALSE; NOT a = FALSE kills the AND options.

3. A student wants to check if a number n is outside the range [10, 20]. Which condition is correct?

  • n < 10 AND n > 20
  • n < 10 OR n > 20
  • NOT (n > 10 AND n < 20)
  • NOT n ≥ 10 OR n ≤ 20
A number is outside [10,20] when it is below 10 OR above 20. AND would be impossible. Option C is close but uses strict inequalities that exclude the endpoints.

4. Consider statements about AND and OR:
I. AND is TRUE only when both operands are TRUE.
II. OR is TRUE only when both operands are TRUE.
III. NOT flips TRUE to FALSE and FALSE to TRUE.

Which are correct?

  • I only
  • I and III only
  • II and III only
  • I, II, and III
Statement I is correct. Statement III is correct. Statement II is false — OR is TRUE when at least one operand is TRUE; it is FALSE only when both are FALSE.

5. NOT (x > 5 OR y < 3) is equivalent to:

  • NOT x > 5 OR NOT y < 3
  • x ≤ 5 AND y ≥ 3
  • x < 5 AND y > 3
  • NOT x > 5 AND NOT y < 3
De Morgan’s Law: NOT(A OR B) = NOT A AND NOT B. NOT(x>5) = x≤5. NOT(y<3) = y≥3. Result: x≤5 AND y≥3.

6. If both p and q are FALSE, which expression is TRUE?

  • p AND q
  • p OR q
  • NOT p AND q
  • NOT p OR NOT q
NOT p = TRUE, NOT q = TRUE. TRUE OR TRUE = TRUE. The others all require at least one of p,q to be TRUE.

7. A loan application is approved if applicant’s credit score ≥ 700 AND income ≥ 50000. Which applicant is incorrectly denied?

  • Score 680, income 60000 — denied
  • Score 720, income 45000 — denied
  • Score 700, income 50000 — denied
  • Score 650, income 40000 — denied
Score 700 ≥ 700 is TRUE and income 50000 ≥ 50000 is TRUE. TRUE AND TRUE = TRUE, so this application should be APPROVED, not denied. All other cases correctly fail one condition.

8. What is the output of:
DISPLAY(NOT(3 > 5) AND (4 = 4))

  • TRUE
  • FALSE
  • NOT TRUE
  • ERROR
NOT(3>5) = NOT(FALSE) = TRUE. (4=4) = TRUE. TRUE AND TRUE = TRUE.

9. A program checks: (temp > 90 OR humidity > 80) AND NOT rain. With temp=95, humidity=70, rain=FALSE, what is the result?

  • FALSE — humidity is not above 80
  • TRUE — temp above 90 satisfies OR, and rain is FALSE
  • TRUE — all three conditions must be met
  • FALSE — NOT rain evaluates before AND
(95>90)=TRUE OR (70>80)=FALSE → TRUE OR FALSE = TRUE. NOT rain = NOT FALSE = TRUE. TRUE AND TRUE = TRUE.

10. Which boolean expression is always FALSE regardless of the value of x?

  • x > 5 AND x < 10
  • x = 5 OR x ≠ 5
  • x > 10 AND x < 5
  • NOT(x = x)
x>10 AND x<5 requires x to simultaneously be above 10 and below 5 — impossible for any real number. This compound is always FALSE. Note: NOT(x=x) = NOT(TRUE) = FALSE is also always false, but x=5 OR x≠5 is always TRUE.

How the AP Exam Tests This

  • Evaluate a compound boolean expression given specific variable values — most common format
  • I/II/III: identify which of three statements about AND/OR/NOT are correct
  • Identify which boolean condition correctly implements a described rule (e.g., valid range check)
  • Spot the error in a boolean condition (AND vs OR, De Morgan’s, impossible compound)
  • Determine what change to a boolean expression would produce a desired result

FAQ

What is De Morgan’s Law and does the AP exam test it?
De Morgan’s Law: NOT(A AND B) = NOT A OR NOT B, and NOT(A OR B) = NOT A AND NOT B. The AP exam tests this implicitly — you won’t be asked to name the law, but questions about negating compound conditions require applying it.
Does the AP exam use && and || or AND and OR?
AP pseudocode uses the words AND, OR, NOT — not the symbols &&, ||, !. Java uses && and ||. Do not bring Java syntax into AP pseudocode answers.
How is = different from ← in AP pseudocode?
In AP pseudocode, ← is assignment (stores a value). = is used for equality comparison inside conditions. x ← 5 stores 5 in x. x = 5 (in an IF condition) asks whether x currently equals 5.

Get in Touch

Whether you're a student, parent, or teacher — I'd love to hear from you.

Just want free AP CS resources?

Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.

Typically responds within 24 hours

Message Sent!

Thanks for reaching out. I'll get back to you within 24 hours.

🏫 Welcome, fellow educator!

I offer curriculum resources, practice materials, and study guides designed for AP CS teachers. Let me know what you're looking for — whether it's classroom materials, a guest speaker, or Teachers Pay Teachers resources.

Email

[email protected]

📚

Courses

AP CSA, CSP, & Cybersecurity

Response Time

Within 24 hours

Prefer email? Reach me directly at [email protected]