AP CSP Reference Sheet
AP CSP Language
Reference Sheet
Complete pseudocode syntax for the AP CSP exam — variables, conditionals, loops, lists, procedures, string operations, and robot procedures. Provided on exam day; practice with it now.
The AP Computer Science Principles exam uses a College Board pseudocode language that appears on every programming question. This AP CSP language reference sheet covers the complete 2025–2026 pseudocode syntax — variables, conditionals, loops, list operations, procedures, string operations, and robot commands. This reference sheet is provided on AP CSP exam day, so you do not need to memorize it; you do need to recognize every construct instantly. Practice with it now so the AP CSP pseudocode cheat sheet feels second nature before test day.
How AP CSP Pseudocode Differs from Real Languages
Variables & Assignment
| Syntax | Meaning | Example |
|---|---|---|
a ← expression |
Assign value to variable | score ← 0 |
a ← b |
Copy value of b into a | temp ← x |
DISPLAY(expression) |
Print to output | DISPLAY(score) |
INPUT() |
Read a value from user | name ← INPUT() |
RANDOM(a, b) |
Random integer between a and b (inclusive) | roll ← RANDOM(1, 6) |
Operators
Arithmetic operators follow standard order of operations. Comparison operators return TRUE or FALSE.
x MOD 2 = 0 checks if x is even. x MOD 2 = 1 checks if x is odd. This appears frequently on the exam.Conditional Statements
| Structure | When to use |
|---|---|
IF (condition) { } |
Run block only if condition is TRUE |
IF (condition) { } ELSE { } |
Run first block if TRUE, second if FALSE |
IF ... ELSE IF ... ELSE |
Chain of conditions, only first TRUE runs |
IF (x = 5) is correct syntax — do not write IF (x == 5).Loops (Iteration)
| Structure | When to use |
|---|---|
REPEAT n TIMES { } |
Run block exactly n times |
REPEAT UNTIL (condition) { } |
Repeat until condition becomes TRUE |
FOR EACH item IN list { } |
Iterate over every element in a list |
List Operations
| Operation | What it does | Example |
|---|---|---|
aList ← [] |
Create empty list | scores ← [] |
aList ← [v1, v2, v3] |
Create list with values | nums ← [1, 2, 3] |
aList[i] |
Access element at index i (starts at 1) |
aList[1] = first item |
aList[i] ← value |
Assign value to position i | aList[2] ← 99 |
INSERT(aList, i, value) |
Insert value at index i; shift right | INSERT(aList, 1, 0) |
APPEND(aList, value) |
Add value to end of list | APPEND(scores, 95) |
REMOVE(aList, i) |
Remove element at index i; shift left | REMOVE(aList, 2) |
LENGTH(aList) |
Returns number of elements |
LENGTH(scores) = 5 |
Procedures (Functions)
| Structure | What it does |
|---|---|
PROCEDURE name(param1, param2) { } |
Define a procedure with parameters |
PROCEDURE name(param) { RETURN(expr) } |
Define a procedure that returns a value |
name(arg1, arg2) |
Call a procedure with arguments |
String Operations
| Operation | What it does | Example |
|---|---|---|
concat(str1, str2) |
Combine two strings | concat("Hello", " World") |
substring(str, start, end) |
Extract characters from start to end |
substring("hello", 2, 4) = "ell" |
len(str) |
Number of characters |
len("hello") = 5 |
str1 + str2 |
Concatenation shorthand |
"AP" + " CSP" = "AP CSP" |
substring("hello", 1, 3) returns "hel" (characters at positions 1, 2, and 3).Robot Procedures
Robot questions appear on the AP CSP exam. The robot lives on a grid and follows these commands.
| Command | What it does |
|---|---|
MOVE_FORWARD() |
Move one square in the direction the robot is currently facing |
ROTATE_LEFT() |
Turn the robot 90° counterclockwise (left), stays in place |
ROTATE_RIGHT() |
Turn the robot 90° clockwise (right), stays in place |
CAN_MOVE(direction) |
Returns TRUE if robot can move in direction: forward, backward, left, right |
Common AP CSP Pseudocode Mistakes
These are the most frequent errors students make when reading or writing AP CSP pseudocode on the exam. Each one has cost real students points.
| Mistake | Wrong | Correct |
|---|---|---|
| Using 0-based index |
aList[0] for first item |
aList[1] is the first item |
| REPEAT UNTIL logic reversed |
REPEAT UNTIL (count < 10) to count to 10 |
REPEAT UNTIL (count > 10) — stops when TRUE |
| Using == for equality | IF (x == 5) |
IF (x = 5) — single = is comparison |
| ROTATE moves the robot |
ROTATE_RIGHT() moves one square right |
ROTATE only changes direction — must call MOVE_FORWARD()
|
| Misreading FOR EACH scope | Assuming item persists after the loop ends |
item is only valid inside the FOR EACH block |
| INSERT vs APPEND confusion | Using INSERT to add to the end |
APPEND(list, value) adds to end; INSERT adds at index |
| MOD with even/odd check |
x MOD 2 = 1 to check if x is even |
x MOD 2 = 0 is even; x MOD 2 = 1 is odd |
Frequently Asked Questions
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]