Skip to content
Marlbridge

AP® Computer Science Principles · Unit 3 · Topic 3.5

Boolean Expressions: Revision Notes (Computer Science Principles 3.5)

One-page recap of Boolean values, relational and logical operators, truth tables and the equivalences students are tested on, with common boundary mistakes.

Recap

  • Boolean value: true or false.
  • Relational operators (=, ≠, >, <, ≥, ≤) compare and produce a Boolean.
  • Logical operators: NOT p flips; p AND q needs both; p OR q needs at least one (inclusive).
  • Use brackets; evaluate small comparisons first, then combine.
  • = tests equality; ← assigns.

Key relationships

Idea Expression Notes
Range, ends included x ≥ lo AND x ≤ hi OR would accept every value
Outside a range x < lo OR x > hi Equivalent to NOT(x ≥ lo AND x ≤ hi)
De Morgan 1 NOT(p AND q) = (NOT p) OR (NOT q) Negating swaps AND and OR
De Morgan 2 NOT(p OR q) = (NOT p) AND (NOT q)
Opposite of ≥ NOT(a ≥ b) = a < b Boundary flips: ≥ becomes <
Divisible by 3 and 5 n MOD 3 = 0 AND n MOD 5 = 0 True for 15, 30, …

Assumptions

  • Each operand of AND/OR/NOT is a Boolean expression or a single Boolean value.
  • Comparisons are evaluated before the logical operators that use them.
  • Brackets in a question show the intended grouping.

Method

  1. Substitute the variable values.
  2. Evaluate each comparison and write true or false beside it.
  3. Evaluate NOT, then combine with AND, then OR (brackets decide).
  4. For “which expression” questions, test each option at the boundary values.

Mistakes to avoid

  • Using OR where AND is needed for a range.
  • Using > where ≥ is needed (or the reverse).
  • Writing x = 5 OR 6.
  • Forgetting that NOT of an AND becomes an OR of NOTs.
  • Stating that OR is false when both sides are true.

Worked mini-example

p ← true
q ← false
DISPLAY(p AND NOT q)
DISPLAY(NOT(p OR q))
DISPLAY((NOT p) OR (NOT q))

Output: true false true

NOT q is true, so p AND true is true. p OR q is true, so NOT(true) is false. (NOT p) is false and (NOT q) is true, so false OR true is true. The last line equals NOT(p AND q), as De Morgan says.

Quick self-check

  1. What is 5 ≥ 5?
  2. Write “x is not between 3 and 8 inclusive” using OR.
  3. Is NOT(a OR b) equal to NOT a OR NOT b?
Answers
  1. true.
  2. x < 3 OR x > 8.
  3. No. It equals NOT a AND NOT b.

Where marks are won and lost

Evaluation questions give values for variables and ask whether a compound expression is true or false; write each comparison’s value before combining. Requirement questions ask which of four expressions matches a sentence, and the traps are OR instead of AND, and > instead of ≥ at the boundaries. Equivalence questions give a condition and ask for an equivalent one, so know both De Morgan forms. Test boundary values, not just typical ones.

Back to the full study guide for worked examples and explanations.

AP® and Advanced Placement® are trademarks registered by the College Board, which is not affiliated with, and does not endorse, this website. Marlbridge is an independent tuition provider. It is not an authorized AP course provider, an AP school or an exam centre, and these resources are not official College Board materials. Reading them or doing simulations does not meet the laboratory requirement of an AP science course.