AP CSP Pseudocode — Read It, Understand It, Solve It
A complete article-style lesson on AP CSP pseudocode with key terms, a step-by-step walkthrough, and a drag-and-drop fill-in-the-blank coding game.
Read It. Understand It.
Solve It with Pseudocode.
A complete guide to AP CSP's official pseudocode — from decoding symbols to writing logic. Master the reference sheet, then prove it with an interactive fill-in-the-blank challenge.
Presentation Talking Points
- What is pseudocode? — It's a plain-English-like way to describe algorithms without worrying about syntax errors. AP CSP uses its own standardized version.
- Why does it matter on the exam? — Every MCQ algorithm question and the Create Task rubric uses this exact notation. Reading it fluently is a tested skill.
- Assignment (
←) is not equality — It means "evaluate the right side and store the result in the variable on the left." A common trap question. - The three pillars of all programs: Sequence (order matters), Selection (IF/ELSE decisions), Iteration (REPEAT loops).
- Lists start at index 1 — Unlike Python or JavaScript. Out-of-bounds access terminates the program — watch for that in tricky MCQs.
- MOD is remainder, not division — 17 MOD 5 = 2. Classic use: check if a number is even with
n MOD 2 = 0. - REPEAT UNTIL stops when the condition becomes true — The opposite of a while-loop mental model. Easy to misread under pressure.
- Procedures can RETURN values — The return value can be stored in a variable. A procedure without RETURN is like a void function.
- How to read any pseudocode problem: (1) Find the variables, (2) Trace the loop, (3) Check the condition, (4) Track what gets returned or displayed.
- The drag-and-drop game at the end uses real exam-style problems. Each blank tests one concept — try to predict the answer before dragging.
What Is Pseudocode?
Pseudocode is a human-readable description of an algorithm — it looks like code, but it's designed to communicate logic, not run on a machine. AP CSP uses a standardized pseudocode that appears on your exam reference sheet. Every question involving algorithms, programs, and robots uses this exact notation, so learning to read it fluently is one of the highest-leverage skills you can build before exam day.
Think of it as a bridge: it's more precise than plain English, but less picky than real code. You'll never get a syntax error for a missing semicolon — but you will get a wrong answer if you misread a ← as an =.
Key Terms Glossary
Every term below appears directly in AP CSP exam problems. Hover over a card to highlight it.
Step-by-Step: How to Read Any Pseudocode Problem
When you encounter pseudocode on the exam, follow these steps in order. Don't jump ahead — trace the code like the computer would.
← statement above the main logic. Write each variable name and its initial value on scratch paper. You can't trace a program you haven't initialized.IF or REPEAT UNTIL, substitute real values into the condition and decide: true or false? Only then decide which branch executes or whether the loop continues.DISPLAY and RETURN as you trace so you don't miss any output.Pseudocode Concepts in Detail
Assignment & Display
score is created and set to 0.Line 2: The right side (
score + 10 = 10) is computed first, then stored back into score. Variable is now 10.Line 3: Outputs
10 followed by a space.
Selection — IF / ELSE
grade ≥ 90 is tested. If true, only the first block runs. If false, only the ELSE block runs. Exactly one branch always executes. Exam trap: An IF without ELSE does nothing when the condition is false — it doesn't crash.
Iteration — REPEAT
REPEAT UNTIL(condition) — checks the condition before each iteration. Stops when the condition becomes true.
Common mistake: Students confuse this with "repeat WHILE false." Remember: it stops when the condition is true, not while it's false.
Lists & FOR EACH
•
aList[1] is the first element.•
LENGTH(aList) returns the count.•
APPEND(aList, val) adds to the end.•
INSERT(aList, i, val) shifts items right.•
REMOVE(aList, i) shifts items left.FOR EACH visits every element in order — you don't need to manage an index variable.
Procedures
isEven(4) is called — the value 4 is copied into parameter n.2.
4 MOD 2 = 0 → true.3.
RETURN(true) immediately exits the procedure.4. The returned value
true is stored in result.No RETURN? The procedure runs its block and exits without sending back a value — like a void function.
Each challenge below has a missing code block marked with a drop zone. Drag the correct token from the code bank into the blank. Read the objectives first — they tell you exactly what the code should do.
- Start with a running total of 0
- Visit each number in
numListone at a time - Add each number to the running total
- Display the final sum after the loop ends
- Assume the first element is the largest to start
- Visit every element in
aListusing FOR EACH - If the current element is greater than the current max, update max
- Return the maximum value found
- Accept a number
nas a parameter - Use the MOD operator to test divisibility
- A number is even when dividing by this value leaves remainder 0
- Return true if even, false otherwise
- Start a counter at 5
- Display the counter value each iteration
- Decrease the counter by 1 each time
- Stop the loop when this variable reaches 0
You filled in all four blanks correctly. You can read AP CSP pseudocode.