AP CSP Reference Sheet

AP Computer Science Principles — 2025–2026

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.
8 Sections Full syntax coverage
Exam Day Sheet provided
30–35% Big Idea 3 of exam
📋 This reference sheet is provided on exam day. You do not need to memorize the syntax — but you do need to recognize it instantly. Practice reading and tracing pseudocode in this format so the reference sheet feels familiar, not foreign, when you open it during the exam.

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

Assignment Uses ← not = x ← 5 (not x = 5)
List Indexing Starts at 1, not 0 myList[1] is the first item
Output DISPLAY, not print() DISPLAY("hello")
Equality Check = for comparison IF (x = 5) not ==
Blocks { } for code blocks No indentation rules
Input INPUT() built-in x ← INPUT()
⚠ The single biggest mistake students make: forgetting lists are 1-indexed. If a list has 5 elements, valid indices are 1 through 5. Accessing index 0 or index 6 is an error.

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)
ⓘ Variables in AP CSP can store numbers, strings, Booleans, or lists. There are no type declarations — the type is inferred from the assigned value.

Operators

Arithmetic operators follow standard order of operations. Comparison operators return TRUE or FALSE.

+Addition
-Subtraction
*Multiplication
/Division
MODRemainder (modulo)
=Equal to
Not equal to
<Less than
>Greater than
<=Less than or equal
>=Greater than or equal
ANDLogical AND
ORLogical OR
NOTLogical NOT
MOD tip: 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 (score >= 90) { DISPLAY("A") } ELSE IF (score >= 80) { DISPLAY("B") } ELSE { DISPLAY("Below B") }
⚠ Conditions in AP CSP use = for equality comparison (not ==). 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
// REPEAT n TIMES REPEAT 5 TIMES { DISPLAY("hello") } // REPEAT UNTIL count ← 1 REPEAT UNTIL (count > 10) { DISPLAY(count) count ← count + 1 } // FOR EACH FOR EACH item IN myList { DISPLAY(item) }
REPEAT UNTIL vs WHILE: AP CSP uses REPEAT UNTIL (not while). The loop continues until the condition is TRUE — so the condition is the stopping condition, not the continuing condition. This trips up many students from Python backgrounds.

List Operations

⚠ AP CSP lists are 1-indexed. The first element is at index 1, not index 0. This is the opposite of Python, JavaScript, and Java.
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
// Traverse a list and find the max nums ← [3, 7, 2, 9, 1] maxVal ← nums[1] FOR EACH n IN nums { IF (n > maxVal) { maxVal ← n } } DISPLAY(maxVal) // displays 9

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
// Procedure without return value PROCEDURE greet(name) { DISPLAY("Hello, " + name) } greet("Alex") // displays: Hello, Alex // Procedure with return value PROCEDURE square(n) { RETURN(n * n) } result ← square(5) // result = 25
Abstraction: Procedures are the primary form of procedural abstraction in AP CSP. The exam frequently tests whether you can trace what a procedure returns given specific inputs.

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"
ⓘ Strings in AP CSP are 1-indexed just like lists. 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
// Move robot to the right 3 squares ROTATE_RIGHT() REPEAT 3 TIMES { MOVE_FORWARD() } // Move until hitting a wall REPEAT UNTIL (NOT CAN_MOVE(forward)) { MOVE_FORWARD() }
⚠ ROTATE_LEFT and ROTATE_RIGHT only change the direction the robot faces — they do not move it. You must call MOVE_FORWARD() to actually move. Common exam trap: assuming ROTATE moves the robot one square.

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

AP Computer Science Principles uses a simplified block-based pseudocode developed by the College Board for the 2025–2026 AP CSP exam. It uses ← for assignment, 1-indexed lists, DISPLAY for output, INPUT for user input, and RANDOM for random numbers. The AP CSP pseudocode reference sheet is not based on any specific programming language, though it resembles Python in some ways.
Yes. The College Board provides the AP CSP language reference sheet on exam day. The 2025–2026 AP CSP exam reference sheet covers pseudocode syntax including assignment, conditionals, loops, list operations, procedures, and robot procedures. You do not need to memorize the syntax, but you must be able to read and trace this pseudocode format fluently. Practice using the AP CSP reference sheet now so it feels familiar on test day.
The four main list operations are: INSERT(list, index, value) to add an element at a position, APPEND(list, value) to add to the end, REMOVE(list, index) to delete an element, and LENGTH(list) to count elements. Remember: AP CSP lists are 1-indexed — the first element is at position 1, not 0.
Robot questions show a robot on a grid. You write or trace code using MOVE_FORWARD(), ROTATE_LEFT(), ROTATE_RIGHT(), and CAN_MOVE(direction). The robot faces a direction and MOVE_FORWARD() moves it one square that way. ROTATE commands only change facing direction — they do not move the robot.
REPEAT UNTIL (condition) runs the block and checks the condition after each iteration. It continues looping while the condition is FALSE and stops when it becomes TRUE. This is the opposite of a while loop, which continues while the condition is TRUE. Students from Python sometimes write the logic backwards on the exam.

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.

Typically responds within 24 hours

Message Sent!

Thanks for reaching out. I'll get back to you within 24 hours.

🏫 Welcome, fellow educator!

I offer curriculum resources, practice materials, and study guides designed for AP CS teachers. Let me know what you're looking for — whether it's classroom materials, a guest speaker, or Teachers Pay Teachers resources.

Email

[email protected]

📚

Courses

AP CSA, CSP, & Cybersecurity

Response Time

Within 24 hours

Prefer email? Reach me directly at [email protected]