6m left·0%
Reading Time: 6 min
Last Updated: March 4, 2026
Main Ideas: 5
Reading Time: 6 min
Last Updated: March 4, 2026
Main Ideas: 5

Topic 3.5 Notes – Boolean Expressions

Verified for 2027 AP® Computer Science Principles Exam
Read aloud
Boolean expressions are how programs make decisions. In Topic 3.5, you focus on values that are either true or false and the operators that create and combine them. These expressions control which code runs and how programs respond to different inputs.

1. What Boolean Values Are

A Boolean value can only be one of two things: true or false. Nothing in between.

Programs use Boolean values to decide what to do. Whenever you see an IF statement or a loop condition, it’s checking a Boolean expression.

A Boolean expression is any expression that evaluates to either true or false.

Two big categories create Boolean values:

  • Relational operators → compare values
  • Logical operators → combine or modify Boolean values

If you see a condition on a quiz, your job is simple: figure out whether it becomes true or false.

2. Relational Operators Compare Two Values

Relational operators compare two variables, expressions, or values. The result is always a Boolean.

The Six You Must Know

These are exactly the ones on the AP reference sheet:

  • = equal to
  • ≠ not equal to
  • > greater than
  • < less than
  • ≥ greater than or equal to
  • ≤ less than or equal to

Each side can be:

  • A number (7)
  • A variable (score)
  • An expression (x + 3)

How to Evaluate One

Example:

x ← 8
y ← 10
x + 2 ≥ y

Step-by-step thinking:

  1. Evaluate arithmetic first
    x + 2 → 8 + 2 → 10
  2. Compare
    10 ≥ 10
  3. Decide
    That’s true

Two common mistakes:

  • Forgetting that = means comparison in pseudocode (assignment uses ←)
  • Forgetting that ≥ and ≤ include equality

Boundary cases show up a lot on multiple choice questions.

3. Logical Operators Combine or Modify Boolean Values

Logical operators work only on Boolean values or Boolean expressions. They also produce a Boolean.

The three you need:

  • NOT
  • AND
  • OR

NOT

NOT condition

It flips the value.

  • NOT true → false
  • NOT false → true

If you see NOT(score = 90), evaluate the inside first, then reverse it.

AND

condition1 AND condition2

True only if both conditions are true.

Think of it as a checklist. If one fails, the whole thing is false.

OR

condition1 OR condition2

True if:

  • The first is true
  • The second is true
  • Both are true

It’s only false when both are false.

Here’s a quick truth summary you should recognize instantly:

ABA AND BA OR B
truetruetruetrue
truefalsefalsetrue
falsetruefalsetrue
falsefalsefalsefalse

And for NOT:

ANOT A
truefalse
falsetrue

If you ever blank during a test, rebuild the logic from this pattern.

4. Evaluating Combined Boolean Expressions

On quizzes and the AP exam, conditions are usually layered.

Example:

(a > 3) AND (b ≤ 12)

How to evaluate:

  1. Evaluate each relational comparison first.
    Each becomes true or false.
  2. Apply NOT if present.
  3. Combine using AND or OR.

Example:

a ← 4
b ← 15
(a > 3) AND (b ≤ 12)
  • a > 3 → true
  • b ≤ 12 → false
  • true AND false → false

Final answer: false

Important rule from the reference sheet:

The operand of a logical operator must be:

  • A Boolean value
  • Or a Boolean expression

You cannot write 5 AND 7. Each side must evaluate to true or false.

Students often lose points by misreading grouped conditions. Slow down and evaluate one piece at a time.

5. Why Boolean Expressions Matter in Programs

Boolean expressions control:

  • Whether an IF statement runs
  • Which branch of code executes
  • Whether a loop continues

Because programs execute statements in order, changing a Boolean condition can completely change the output.

When the AP gives you a code segment and asks what prints, almost always you’re tracing Boolean conditions somewhere.

Key Takeaways

Every relational comparison evaluates to either true or false, never a number.
= checks equality in pseudocode; ← assigns a value.
AND is only true when both sides are true.
OR is only false when both sides are false.
Evaluate arithmetic first, then relational comparisons, then logical operators.
The operand of NOT, AND, or OR must already be a Boolean value or expression.

AP® is a trademark registered by the College Board, which is not affiliated with, and does not endorse this website.

Notes

1 credit used · 5/5 remaining