AP CSP Pseudocode Reference — Every Exam Construct Explained

The AP Computer Science Principles exam pseudocode explained in plain language with worked examples: assignment, DISPLAY and INPUT, MOD, Boolean logic, IF and ELSE, REPEAT loops, 1-indexed lists, procedures, RANDOM and the robot. Free practice in the block editor.

Common questions

Is the AP CSP pseudocode reference sheet provided during the exam?
Yes. College Board includes the AP Computer Science Principles Exam Reference Sheet with the exam, so you never have to memorize the syntax. What the exam does test is reading speed and accuracy: many of the 70 multiple-choice questions show a short program in this pseudocode and ask what it displays, which line has an error, or which change would fix it. Knowing the constructs cold means you spend your time tracing, not decoding.
Do lists in AP CSP pseudocode start at 0 or 1?
At 1. aList[1] is the first element and aList[LENGTH(aList)] is the last; index 0 and any index past the length are errors. This is the single most common trap on the exam, because Python and JavaScript both start at 0. A loop that runs from 1 to LENGTH(aList) visits every element exactly once.
What does MOD do in AP CSP pseudocode?
a MOD b is the remainder when a is divided by b, for a whole number a that is at least 0 and a whole number b greater than 0: 17 MOD 5 is 2, 10 MOD 2 is 0 and 7 MOD 10 is 7. It is how the exam tests even or odd (n MOD 2 = 0), reads the last digit (n MOD 10) and wraps a counter around a range. Plain division with / is ordinary division, so 7 / 2 is 3.5, not 3.
What is the difference between REPEAT n TIMES and REPEAT UNTIL?
REPEAT n TIMES runs its block a fixed number of times, like a counted loop. REPEAT UNTIL (condition) checks the condition before each pass and runs the block only while the condition is false; it stops the first time the condition is true. If the condition is already true at the start the block never runs, and if it never becomes true the loop never ends. In Python terms it is while not condition, so read the condition as the stopping rule, not the keep-going rule.
Is AP CSP pseudocode a real programming language?
No. It is a reading language College Board designed so that exam questions do not depend on Python, JavaScript, Java or whichever block language a class used. You never submit pseudocode: the Create performance task is written in a real language of your choice. Learning the pseudocode is about recognizing its constructs instantly and translating them to and from the language you program in.
Where can I practice AP CSP pseudocode for free?
On CS++: the free AP CSP Pseudocode Blocks Editor at csplusplus.com/blocks lets you build programs block by block in the exam’s form and drive the robot on a grid, with no account; the free AP CSP course has an AP CSP Pseudocode Practice lesson and a quick reference lesson in its exam-review unit; the AP CSP mock exams use the pseudocode the way the real exam does; and the AP CSP vocabulary glossary covers the terms. This page and the editor need no account at all.

Loading the interactive version of this page…