Fiveable

⌨️AP Computer Science Principles Unit 3 Review

QR code for AP Computer Science Principles practice questions

3.5 Boolean Expressions

3.5 Boolean Expressions

Written by the Fiveable Content Team • Last updated June 2026
Verified for the 2027 exam
Verified for the 2027 examWritten by the Fiveable Content Team • Last updated June 2026
⌨️AP Computer Science Principles
Unit & Topic Study Guides

AP Computer Science Principles Exam

Pep mascot

Boolean expressions evaluate to either true or false. You build them with relational operators (=, , >, <, , ) to compare values, and you combine those results with logical operators (NOT, AND, OR). For AP Computer Science Principles, trace each comparison carefully before deciding whether a conditional or loop runs.

Why This Matters for the AP Computer Science Principles Exam

Boolean logic shows up constantly in AP Computer Science Principles because conditions control how programs make decisions. On multiple-choice questions, you will often need to determine the result of a code segment, and that frequently means tracing what a Boolean expression evaluates to before an IF runs or a REPEAT UNTIL loop stops. The exam uses its own pseudocode on the reference sheet, so you should be able to read relational and logical operators in that notation, not just in one language.

This topic also supports your Create performance task. When you write conditionals or loops in your own program, you are writing Boolean expressions, and your written responses need to explain how your code behaves. Knowing exactly when an expression is true or false makes that explanation accurate.

Key Takeaways

  • A Boolean value is either true or false, and any relational or logical comparison evaluates to one of those two values.
  • The relational operators on the reference sheet are =, , >, <, , and , and they compare two variables, expressions, or values.
  • The logical operators are NOT, AND, and OR, and they work on Boolean expressions or single Boolean values.
  • NOT flips a value, AND is true only when both conditions are true, and OR is true when at least one condition is true.
  • Relational operators handle one comparison at a time, while logical operators let you combine multiple conditions into one expression.
  • The reference sheet uses = for comparison in pseudocode, which is different from how some languages write equality.

Boolean Values and Relational Operators

A Boolean value is either true or false. Those are the only two options. Whenever you compare two things, the result is a Boolean value.

Relational operators test the relationship between two variables, expressions, or values. The exam reference sheet provides these:

OperatorMeaning
a = btrue if a equals b
a ≠ btrue if a does not equal b
a > btrue if a is greater than b
a < btrue if a is less than b
a ≥ btrue if a is greater than or equal to b
a ≤ btrue if a is less than or equal to b

A comparison using a relational operator always evaluates to a single Boolean value. For example, a = b evaluates to true if a and b are equal; otherwise it evaluates to false.

Here is the same idea in a real language. In Python:

</>Code
y = 5
x = 55
print (x > y)

This prints True because 55 is greater than 5.

Logical Operators: NOT, AND, OR

Logical operators let you combine or flip conditions. They each evaluate to a Boolean value. The operand for a logical operator is either a Boolean expression or a single Boolean value. Relational operators only test one comparison at a time, but logical operators let you work with several conditions at once.

NOT

NOT condition evaluates to true if the condition is false, and false if the condition is true. It reverses the result.

</>Code
y = 5
x = 55
print (not y >= 5)

This prints False. Since y equals 5, the condition y >= 5 is true, and NOT reverses it to false.

AND

condition1 AND condition2 evaluates to true only if both conditions are true. If either one is false, the whole expression is false.

</>Code
y = 5
x = 55
print (y >= 5 and x <= 44)

This prints False. Even though y >= 5 is true, x <= 44 is false, and AND needs both to be true.

OR

condition1 OR condition2 evaluates to true if at least one condition is true. That includes the case where both are true. It is only false when both conditions are false.

</>Code
y = 5
x = 55
print (y >= 5 or x <= 44)

This prints True. The second condition is false, but the first condition is true, and OR only needs one.

Quick Truth Reference

ABA AND BA OR BNOT A
truetruetruetruefalse
truefalsefalsetruefalse
falsetruefalsetruetrue
falsefalsefalsefalsetrue

How to Use This on the AP Computer Science Principles Exam

Code Tracing

When a question gives you a code segment, plug in the actual values and evaluate the Boolean expression step by step. Do the relational comparisons first to get true or false, then apply NOT, AND, and OR. Use parentheses to keep compound expressions organized so you do not lose track of which condition is which.

Common Trap

For AND, check both sides before deciding. It is easy to see one true condition and assume the whole thing is true, but AND requires both. For OR, remember a single true condition makes the whole expression true.

Create Performance Task

Every conditional and loop you write uses a Boolean expression. When your written responses ask you to explain how part of your program works, state clearly what condition is being tested and what happens when it is true versus false. Precise Boolean reasoning makes your explanation match what the code actually does.

Common Misconceptions

  • OR is not exclusive. condition1 OR condition2 is still true when both conditions are true, not only when exactly one is true.
  • AND needs both conditions to be true. One true side is not enough.
  • In the exam pseudocode, = is a comparison that returns a Boolean, while is assignment. Mixing these up changes what a line does.
  • Relational operators compare values; logical operators combine Boolean results. You usually need relational operators to produce the true or false values that logical operators then work on.
  • NOT reverses the final Boolean result of the condition. Apply the comparison first, then flip it.

Vocabulary

The following words are mentioned explicitly in the College Board Course and Exam Description for this topic.

Term

Definition

AND

A logical operator that evaluates to true only if both conditions are true; otherwise it evaluates to false.

Boolean expression

An expression that evaluates to either true or false, often composed of conditions combined with logical operators.

Boolean value

A value that is either true or false, representing the result of a comparison or logical operation.

logical operators

Operators such as NOT, AND, and OR that are used to combine or modify Boolean expressions to produce a Boolean result.

NOT

A logical operator that evaluates to true if the condition is false, and evaluates to false if the condition is true.

operand

A value or expression that a logical operator acts upon, which can be either a Boolean expression or a single Boolean value.

OR

A logical operator that evaluates to true if at least one condition is true; otherwise it evaluates to false.

relational operators

Symbols used to compare two variables, expressions, or values, including =, ≠, >, <, ≥, and ≤.

Frequently Asked Questions

What is a Boolean expression in AP CSP?

A Boolean expression is an expression that evaluates to either true or false. AP CSP uses Boolean expressions in comparisons, conditionals, loops, and logical expressions.

Which relational operators are on the AP CSP reference sheet?

The AP CSP reference sheet uses =, not equal, >, <, greater than or equal to, and less than or equal to. Each comparison tests a relationship between two values and evaluates to a Boolean value.

What do NOT, AND, and OR mean in AP CSP?

NOT flips a Boolean value, AND is true only when both conditions are true, and OR is true when at least one condition is true. These logical operators combine or change Boolean values.

How do Boolean expressions appear on the AP CSP exam?

They often appear in code-tracing questions where you decide whether an IF statement runs or when a loop stops. Read each comparison first, then apply NOT, AND, or OR to find the final true or false value.

What is a common mistake with Boolean expressions?

A common mistake is reading OR as if it means exactly one condition is true. In AP CSP, OR is true if condition1 is true, condition2 is true, or both are true.

How are Boolean expressions used in the Create performance task?

When your program uses conditionals or loops, it likely uses Boolean expressions to decide what happens next. Understanding them helps you explain how your code responds to different inputs or states.

Pep mascot
Upgrade your Fiveable account to print any study guide

Download study guides as beautiful PDFs See example

Print or share PDFs with your students

Always prints our latest, updated content

Mark up and annotate as you study

Click below to go to billing portal → update your plan → choose Yearly→ and select "Fiveable Share Plan". Only pay the difference

Plan is open to all students, teachers, parents, etc
Pep mascot
Upgrade your Fiveable account to export vocabulary

Download study guides as beautiful PDFs See example

Print or share PDFs with your students

Always prints our latest, updated content

Mark up and annotate as you study

Plan is open to all students, teachers, parents, etc
report an error
description

screenshots help us find and fix the issue faster (optional)

add screenshot