Reading Pseudocode
The AP Computer Science Principles Reference Sheet, decoded · ~30–45 min
What This Lesson Covers
The AP CSP exam uses its own language-agnostic pseudocode — not Python, not Java. The good news: you get the full reference sheet on the exam. You don't have to memorize syntax. You just have to read it confidently.
This lesson is a fast tour of every section of the reference sheet, with the gotchas that trip up most students.
1. The AP Reference SheetProvided on the exam
The College Board provides a Reference Sheet at the start of the exam booklet. It explains every pseudocode instruction you might see. It is not a list of code to memorize — it is your dictionary while answering questions.
The reference sheet has both a text format (what we'll use here) and a block format (drag-and-drop blocks like Scratch). Both formats show up on the exam. They mean the same thing — only the appearance differs.
Open the AP CSP Reference Sheet (PDF)
This is the exact reference sheet you'll have printed in your exam booklet. Open it in another tab and keep it handy as you work through this lesson.
2. Assignment vs. Equality
This is the #1 source of student confusion on AP CSP code questions:
| Symbol | What it means | Example |
|---|---|---|
| ← (left arrow) | Assignment. Evaluate the right side, then store the result in the variable on the left. | x ← 5 — puts the value 5 in x |
| = (equals sign) | Equality test. Evaluates to true if the two sides are equal, false otherwise. | x = 5 — is x equal to 5? |
Other "actions": DISPLAY and INPUT
- DISPLAY(expression) — prints the value, followed by a space.
- INPUT() — pauses and returns whatever the user types.
3. Arithmetic Operators
Standard math: +, -, *, /. Normal order of operations. Plus two special ones:
| Operator | Meaning | Example |
|---|---|---|
| a MOD b | The remainder when a is divided by b. Same precedence as * and /. | 17 MOD 5 evaluates to 2 (because 17 = 3×5 + 2) |
| RANDOM(a, b) | Returns a random integer from a to b, inclusive of both endpoints. Each value is equally likely. | RANDOM(1, 3) could return 1, 2, or 3. |
4. Comparison & Boolean Operators
Comparison (yes/no questions)
These all produce a Boolean (true or false):
| Operator | Meaning |
|---|---|
| a = b | Equal to |
| a ≠ b | Not equal to |
| a > b / a < b | Greater than / less than |
| a ≥ b / a ≤ b | Greater-than-or-equal / less-than-or-equal |
Boolean combinators
| Operator | Meaning |
|---|---|
| NOT condition | true if condition is false; flips the value. |
| a AND b | true only when both are true. |
| a OR b | true when at least one is true (including both). |
To be eligible for a particular ride at an amusement park, a person must be at least 12 years old and must be between 50 and 80 inches tall, inclusive. Let age represent the person's age in years, and height the person's height in inches. Which expression evaluates to true if and only if the person is eligible for the ride?
5. Selection: IF and IF / ELSE
IF(condition)
{
<block of statements>
}
Run the block only if the condition is true. Otherwise, skip it entirely.
IF(condition) { <first block> } ELSE { <second block> }
Run the first block if the condition is true; otherwise run the second block. Exactly one of the two blocks runs.
Result X is expected to occur 25% of the time and result Y 75% of the time. The following code is intended to simulate 100 trials, but it counted only 94 trials (24 + 70). Which change fixes the bug?
Line 1: xCount ← 0 Line 2: yCount ← 0 Line 3: REPEAT 100 TIMES Line 4: { Line 5: IF(RANDOM(1, 4) = 1) Line 6: { Line 7: xCount ← xCount + 1 Line 8: } Line 9: IF(RANDOM(1, 4) > 1) Line 10: { Line 11: yCount ← yCount + 1 Line 12: } Line 13: }
6. Iteration: REPEAT and FOR EACH
| Loop | What it does |
|---|---|
| REPEAT n TIMES | Runs the block exactly n times. |
| REPEAT UNTIL(condition) | Keeps running the block until the condition becomes true. If the condition is already true at the start, the block doesn't run at all. |
| FOR EACH item IN aList | Assigns each element of aList to the variable item, in order from first to last. The block runs once per element. |
7. Lists
So for aList ← [10, 20, 30]:
- aList[1] is 10 (first element)
- aList[2] is 20
- aList[3] is 30 (last element)
- aList[0] — error! the program terminates.
List operations
| Operation | What it does |
|---|---|
| aList ← [v1, v2, v3] | Creates the list with those values at indices 1, 2, 3. |
| aList[i] ← x | Replaces the value at index i with x. |
| APPEND(aList, value) | Adds value to the end. List length grows by 1. |
| INSERT(aList, i, value) | Shifts elements at i and beyond to the right, then places value at index i. Length grows by 1. |
| REMOVE(aList, i) | Deletes the item at index i, shifts the rest left. Length shrinks by 1. |
| LENGTH(aList) | Returns the number of elements in the list. |
8. Procedures and RETURN
PROCEDURE procName(parameter1, parameter2, ...) { <block of statements> RETURN(expression) }
A procedure is a named, reusable block of code that takes inputs (called parameters) and may return a result.
Calling a procedure
- procName(arg1, arg2) — runs the procedure with those arguments.
- result ← procName(arg1, arg2) — runs it and stores the returned value in result.
The procedure below is intended to return true if numberList is "increasing" (each value ≥ the one before) and false otherwise. It contains a bug. Which change is needed?
Line 1: PROCEDURE isIncreasing(numberList) Line 2: { Line 3: count ← 2 Line 4: REPEAT UNTIL(count > LENGTH(numberList)) Line 5: { Line 6: IF(numberList[count] < numberList[count - 1]) Line 7: { Line 8: RETURN(true) Line 9: } Line 10: count ← count + 1 Line 11: } Line 12: RETURN(false) Line 13: }
9. Robot Commands
Some exam questions use a small robot in a grid. The reference sheet defines four commands:
| Command | What it does |
|---|---|
| MOVE_FORWARD() | Moves the robot one square forward, in the direction it is currently facing. |
| ROTATE_LEFT() | Turns the robot 90° counterclockwise in place. Does not move it. |
| ROTATE_RIGHT() | Turns the robot 90° clockwise in place. Does not move it. |
| CAN_MOVE(direction) | Returns true if the square in that direction is open and on the grid. direction can be forward, backward, left, or right. |
10. How to Trace Code Like a Pro
"Trace tables" turn confusing code into a simple ledger. The trick: pick a fresh sheet of scratch paper, draw one column per variable, and write down every value as it changes.
Example trace
x ← 3 y ← 5 REPEAT 3 TIMES { x ← x + y y ← y - 1 } DISPLAY(x)
| Step | x | y | Notes |
|---|---|---|---|
| Start | 3 | 5 | Initial assignments |
| Loop 1 | 8 | 4 | x = 3+5, y = 5−1 |
| Loop 2 | 12 | 3 | x = 8+4, y = 4−1 |
| Loop 3 | 15 | 2 | x = 12+3, y = 3−1 |
| Display | 15 | — | Final answer |
Misconception Lightning Round
Click True or False:
"You have to memorize the reference sheet because it isn't given to you on the exam."
"In AP CSP pseudocode, the first element of a list is at index 0."
"The symbol = stores a value in a variable."
"REPEAT UNTIL(condition) keeps looping while the condition is true."
"17 MOD 5 evaluates to 3 or 3.4 (the quotient)."
"aList[LENGTH(aList)] always evaluates to the last element of the list."
What's NOT on the AP CSP Exam
Don't spend study time on these — they're real programming concepts but they're not tested:
- Memorizing Python, Java, or JavaScript syntax Out of scope
- Object-oriented programming, classes, inheritance Out of scope
- Pointers, memory management, types beyond {number, Boolean, string, list} Out of scope
- Recursion as a tested topic (it can show up incidentally, but is not on the framework) Out of scope
- Specific sorting algorithm names (bubble sort, quicksort, etc.) Out of scope
- Big-O notation specifics — you only need "reasonable time" vs. "not reasonable time" Out of scope
Translation: The exam is testing whether you can read code, not whether you can write a specific language. Reference sheet + tracing skill = most pseudocode questions.
More Info — Trusted Sources to Verify or Go Deeper
Everything on this page is drawn directly from the College Board's official AP CSP Reference Sheet (the same one printed inside the exam booklet) and the 2021 released practice exam. If you want to see the original document or read deeper, these are the references your teachers and the College Board treat as authoritative.
- College Board AP Central — AP CSP Course Page — The official source. The Course and Exam Description (CED) PDF contains the full reference sheet.
- AP CSP Course and Exam Description (PDF) — Reference sheet appears in Appendix A. This is the document the exam booklet is reprinted from.
- AP CSP Exam Reference Sheet (PDF) — Just the reference sheet, standalone. Print it. Read it. You'll see the exact same one on exam day.
- Khan Academy — AP Computer Science Principles — Free video lessons with worked pseudocode examples in the same style as the exam.
- Mobile CSP Textbook — Open-source AP CSP textbook used by teachers nationwide. Strong chapters on lists, iteration, and procedures.
- apcsexamprep.com — Big Idea 3 (Algorithms & Programming) — Practice questions and walkthroughs explicitly aligned to the AP CSP CED.