---
title: "Relational Operator — AP CSP Definition & Exam Guide"
description: "A relational operator (=, ≠, >, <, ≥, ≤) compares two values and returns true or false. It powers every Boolean expression, IF statement, and loop condition in AP CSP."
canonical: "https://fiveable.me/ap-comp-sci-p/key-terms/relational-operator"
type: "key-term"
subject: "AP Computer Science Principles"
---

# Relational Operator — AP CSP Definition & Exam Guide

## Definition

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).

## What It Is

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](/ap-comp-sci-p/key-terms/variable "fv-autolink"), two values, or two whole expressions, the comparison evaluates to a [Boolean value](/ap-comp-sci-p/unit-3/boolean-expressions/study-guide/LkLTi80KQM04AnmNBxCq "fv-autolink") (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](/ap-comp-sci-p/key-terms/ap-pseudocode "fv-autolink"), `=` 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 It Matters

Relational operators live in Topic 3.5 (Boolean Expressions) in [Unit 3](/ap-comp-sci-p/unit-3 "fv-autolink"), and they directly support learning objective [AP Comp Sci P](/ap-comp-sci-p "fv-autolink") 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.

## Connections

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

Relational operators produce Boolean values; logical operators combine them. An [expression](/ap-comp-sci-p/key-terms/expression "fv-autolink") 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](/ap-comp-sci-p/key-terms/operator "fv-autolink") `=` 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](/ap-comp-sci-p/key-terms/condition "fv-autolink") 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.

## On the AP 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 Takeaways

- 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.

## FAQs

### 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.

## Structured Data

```json
{"@context":"https://schema.org","@graph":[{"@type":"LearningResource","@id":"https://fiveable.me/ap-comp-sci-p/key-terms/relational-operator#resource","name":"Relational Operator — AP CSP Definition & Exam Guide","url":"https://fiveable.me/ap-comp-sci-p/key-terms/relational-operator","learningResourceType":"Concept explainer","educationalLevel":"AP® / High School","about":{"@id":"https://fiveable.me/ap-comp-sci-p/key-terms/relational-operator#term"},"audience":{"@type":"EducationalAudience","educationalRole":"student"},"dateModified":"2026-06-11T00:50:13.703Z","isPartOf":{"@type":"Collection","name":"AP Computer Science Principles Key Terms","url":"https://fiveable.me/ap-comp-sci-p/key-terms"},"publisher":{"@type":"Organization","name":"Fiveable","url":"https://fiveable.me"}},{"@type":"DefinedTerm","@id":"https://fiveable.me/ap-comp-sci-p/key-terms/relational-operator#term","name":"Relational Operator","description":"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).","url":"https://fiveable.me/ap-comp-sci-p/key-terms/relational-operator","inDefinedTermSet":{"@type":"DefinedTermSet","name":"AP Computer Science Principles Key Terms","url":"https://fiveable.me/ap-comp-sci-p/key-terms"},"educationalAlignment":[{"@type":"AlignmentObject","alignmentType":"educationalSubject","educationalFramework":"AP® Course and Exam Description","targetName":"AP® Computer Science Principles Unit 3, Topic 3.5, LO 3.5.A"},{"@type":"AlignmentObject","alignmentType":"educationalSubject","educationalFramework":"AP® Course and Exam Description","targetName":"AP® Computer Science Principles Unit 3, Topic 3.5, LO 3.5.B"}]},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is a relational operator in AP Computer Science Principles?","acceptedAnswer":{"@type":"Answer","text":"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 ≤."}},{"@type":"Question","name":"Does = mean assignment on the AP CSP exam?","acceptedAnswer":{"@type":"Answer","text":"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."}},{"@type":"Question","name":"What's the difference between relational operators and logical operators?","acceptedAnswer":{"@type":"Answer","text":"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."}},{"@type":"Question","name":"What relational operator means not equal in AP CSP?","acceptedAnswer":{"@type":"Answer","text":"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."}},{"@type":"Question","name":"Can one relational operator replace (a > b) OR (a = b)?","acceptedAnswer":{"@type":"Answer","text":"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."}}]},{"@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"AP Computer Science Principles","item":"https://fiveable.me/ap-comp-sci-p"},{"@type":"ListItem","position":2,"name":"Key Terms","item":"https://fiveable.me/ap-comp-sci-p/key-terms"},{"@type":"ListItem","position":3,"name":"Unit 3","item":"https://fiveable.me/ap-comp-sci-p/unit-3"},{"@type":"ListItem","position":4,"name":"Relational Operator"}]}]}
```
