Relational Operator

In AP Computer Science Principles, a relational operator is a symbol (=, ≠, >, <, ≥, ≤ on the exam reference sheet) that compares two values, variables, or expressions and evaluates to a single Boolean value: true or false (EK AAP-2.E.2).

Verified for the 2027 AP Computer Science Principles examLast updated June 2026

What is Relational Operator?

A relational operator compares two things and answers one question: is this relationship true or false? The AP exam reference sheet gives you exactly six of them: = (equal), (not equal), > (greater than), < (less than), (greater than or equal), and (less than or equal). Whatever you put on either side, two variables, two values, or two whole expressions, the comparison evaluates to a Boolean value (EK AAP-2.E.1). So score = 100 evaluates to true if score holds 100, and false otherwise.

Heads up on the biggest trap in the whole course. In AP pseudocode, = means comparison, not assignment. Assignment uses the arrow (score ← 100). If you've written Java or Python, your instinct says == for comparison and = for assignment, and the AP exam flips that. There is no == anywhere in AP pseudocode. One symbol, =, and it always means "are these equal?"

Why Relational Operator matters in AP Computer Science Principles

Relational operators live in Topic 3.5 (Boolean Expressions) in Unit 3, and they directly support learning objective AP Comp Sci P 3.5.A, which says you need to both write and evaluate expressions using relational operators. But their reach goes way beyond one topic. Every IF statement needs a condition, every REPEAT UNTIL loop needs a stopping test, and almost every one of those conditions is built from relational operators. If you can't evaluate a ≥ b correctly, you can't trace selection or iteration code, and code tracing is a huge chunk of the multiple-choice exam. Think of relational operators as the atoms that Boolean logic is built from.

How Relational Operator connects across the course

Logical Operators: NOT, AND, OR (Unit 3)

Relational operators produce Boolean values; logical operators combine them. An expression like (year MOD 4 = 0) AND (year MOD 100 ≠ 0) uses relational operators to make two true/false answers, then AND to merge them into one. LO 3.5.B covers this combining step, and exam questions love stacking the two together.

Equality Operator (Unit 3)

The equality operator = is the relational operator most likely to trip you up, because in AP pseudocode it tests equality instead of assigning a value. Its partner tests inequality, which is what you'd reach for when checking something like "score is not equal to 100."

Selection and Conditionals (Unit 3)

IF statements don't do anything without a condition to check, and that condition is almost always a relational comparison. IF (temp > 90) only runs its block when the relational operator evaluates to true. Relational operators are the decision-making fuel for Topic 3.6.

Iteration and Loop Conditions (Unit 3)

REPEAT UNTIL loops keep running until their condition becomes true, and that condition is usually a relational test like count ≥ 10. Misreading ≥ as > is a classic way to be off by one iteration when tracing loop questions.

Is Relational Operator on the AP Computer Science Principles exam?

Relational operators show up constantly in multiple-choice code-tracing questions. You'll be asked things like which Boolean expression evaluates to true when x is 10, which operator checks that a score is not equal to 100, or how to build a compound condition like the leap-year test (divisible by 4, except divisible by 100, unless divisible by 400). A favorite question type asks you to simplify: (a > b) OR (a = b) can be replaced by the single operator a ≥ b, so know how the six operators relate to each other. On the Create Performance Task side, your selection statement almost certainly uses a relational operator inside its condition, so be ready to explain what your comparison tests and why.

Relational Operator vs Logical Operator

Relational operators (=, ≠, >, <, ≥, ≤) compare two values and produce a Boolean. Logical operators (NOT, AND, OR) take Boolean values as input and combine or flip them. Easy check: relational operators sit between numbers or variables, logical operators sit between conditions. In (a > b) AND (c < d), the > and < are relational, the AND is logical.

Key things to remember about Relational Operator

  • A relational operator compares two values, variables, or expressions and always evaluates to a Boolean value, either true or false.

  • The AP exam reference sheet gives you six relational operators: =, ≠, >, <, ≥, and ≤.

  • In AP pseudocode, = is a comparison (does a equal b?), not an assignment; assignment uses the arrow ←.

  • Relational operators build the conditions inside IF statements and loops, so every code-tracing question that branches or repeats depends on them.

  • Know how operators combine and simplify: (a > b) OR (a = b) is the same thing as a ≥ b.

  • Relational operators output Booleans; logical operators (NOT, AND, OR) take those Booleans as input, which is how compound conditions like the leap-year check get built.

Frequently asked questions about Relational Operator

What is a relational operator in AP Computer Science Principles?

A relational operator is a symbol that compares two values, variables, or expressions and evaluates to a Boolean (true or false). The AP exam reference sheet provides six: =, ≠, >, <, ≥, and ≤.

Does = mean assignment on the AP CSP exam?

No. In AP pseudocode, = is the equality comparison operator, so a = b asks whether a and b are equal and returns true or false. Assignment uses the arrow, as in a ← b. There is no == in AP pseudocode.

What's the difference between relational operators and logical operators?

Relational operators (=, ≠, >, <, ≥, ≤) compare two values and produce a Boolean. Logical operators (NOT, AND, OR) combine or invert Boolean values. You typically use relational operators first, then logical operators to join the results into one compound condition.

What relational operator means not equal in AP CSP?

The ≠ symbol. So if a program needs to check that a score is not equal to 100, the expression is score ≠ 100, which evaluates to true whenever score is anything other than 100.

Can one relational operator replace (a > b) OR (a = b)?

Yes, a ≥ b does the exact same job. This kind of simplification is a common multiple-choice question, so know that ≥ covers both "greater than" and "equal to" in a single test.