AP CSP Ap Pseudocode Syntax
AP CSP Pseudocode Syntax: Complete Guide (2025‑2026)
AP pseudocode is College Board’s custom language used exclusively on the AP CSP exam. It is not Java, Python, or any real language. Key differences: assignment uses ← not =, list indexing starts at 1 not 0, = means comparison not assignment in conditions, and loops use REPEAT/FOR EACH not for/while. Mixing Java or Python habits into AP pseudocode answers costs points.
Contents
Quick Reference Card
AP pseudocode has unique syntax that differs from both Java and Python. Never bring language-specific habits onto the AP exam.
Critical Syntax Differences
-
x ← 5for assignment -
IF x = 5for comparison (= not ==) -
list[1]for first element -
REPEAT UNTIL x > 10exits when TRUE -
x MOD yfor remainder (not %)
-
x = 5for assignment (Java/Python style) -
IF x == 5(Java comparison, not AP) -
list[0]for first element (0-indexed) -
while x <= 10:(Python syntax) -
x % yfor remainder (Java/Python)
Code Trace Gauntlet
What displays?
yes a*b=12. 12>10 is TRUE. IF block runs, displays yes.
What are the three outputs?
2 1 0 17 MOD 5 = 2 (17 = 3*5+2). 10 MOD 3 = 1 (10 = 3*3+1). 8 MOD 2 = 0 (evenly divisible).
What displays? Notice = is used for both assignment and comparison.
equal Line 1: ← is assignment. Line 2: = inside IF is comparison. x=5 is TRUE. Displays equal.
What does firstLast return?
12 lst[1]=3 (first), lst[LENGTH(lst)]=lst[4]=9 (last). 3+9=12.
Spot the Bug
Uses = for assignment instead of ←. In AP pseudocode, = inside an IF condition means comparison; ← is always assignment. Fix: count ← 0 and count ← count + 1.
AP lists are 1-indexed. scores[0] is an error. Fix: scores[1] returns 90.
Common Exam Pitfalls
The AP exam uses ← for assignment. = appears only in conditions (as equality comparison). Never write x = 5 as an assignment statement.
In AP pseudocode, = (single equals) is the comparison operator inside IF conditions. Java’s == and Python’s == are not used.
AP lists start at 1. list[1] is the first element. Do not apply Python or Java 0-based habits.
AP pseudocode uses the keyword MOD. 10 MOD 3 = 1. Writing 10 % 3 uses Java/Python syntax and is wrong on the AP exam.
Check for Understanding
1. In AP pseudocode, which correctly assigns the value 7 to variable n?
- n = 7
- n ← 7
- n == 7
- n := 7
2. In AP pseudocode, which correctly tests whether x equals 10 inside an IF condition?
- IF x ← 10
- IF x == 10
- IF x = 10
- IF x.equals(10)
3. DISPLAY(15 MOD 4) outputs:
- 3
- 4
- 3.75
- 0
4. lst ← [10,20,30] outputs:
DISPLAY(lst[1])
- 0 — first index is 0
- 10 — first index is 1 in AP pseudocode
- 20
- Error
5. Which statement about AP pseudocode syntax is correct?
- REPEAT UNTIL loops exit when the condition is FALSE
- FOR EACH provides an index variable like a Java for loop
- All list operations (APPEND, INSERT, REMOVE) modify the list in place
- Procedures must always include a RETURN statement
6. Which AP pseudocode expression correctly checks if n is odd?
- n MOD 2 = 1
- n % 2 == 1
- n MOD 2 != 0
- n / 2 = 1
7. Consider: I. ← is used for assignment in AP pseudocode. II. = inside an IF condition tests for equality. III. AP list indices start at 0. Which are correct?
- I only
- I and II only
- I, II, and III
- III only
8. x ← 10
IF x MOD 3 = 1
DISPLAY("yes")
ELSE
DISPLAY("no")
- yes
- no
- 1
- Error
9. What does DISPLAY(LENGTH([5,10,15,20])) output?
- 3
- 4
- 20
- 5
10. A student writes REPEAT UNTIL count < 10 with count starting at 1. How many times does the body run?
- 0 — condition already true, REPEAT UNTIL skips
- 1 — body runs once then condition checked and found TRUE
- 9 — runs until count reaches 9
- 10 — runs until count reaches 10
How the AP Exam Tests This
- Read a code segment and identify what is displayed or what value a variable holds
- Identify syntax errors (wrong operator, wrong index base, wrong loop keyword)
- Evaluate a MOD expression with specific values
- Determine whether AP pseudocode or Java/Python syntax is used correctly
- I/II/III: identify which statements about AP pseudocode syntax are correct
FAQ
Get in Touch
Whether you're a student, parent, or teacher — I'd love to hear from you.
Just want free AP CS resources?
Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.
Message Sent!
Thanks for reaching out. I'll get back to you within 24 hours.
Prefer email? Reach me directly at [email protected]