AP Computer Science Principles Unit 3: Algorithms & Programming
Study variables, conditionals, iteration, procedures, algorithms, lists with exam-format practice and rubric-based scoring.
Start AP CSP Practice · Full Study Guide
AP and Advanced Placement are trademarks of College Board. AimFive is not affiliated with or endorsed by College Board.
Inside This Unit: The Full Breakdown
This unit covers the building blocks of programming: variables, conditionals, loops, lists, and procedures. You learn to write algorithms that solve problems using sequencing, selection, and iteration.
Why it matters
Algorithms and programming form the largest portion of the AP CSP exam — roughly 30% of multiple-choice questions. The Create Performance Task also requires demonstrating these programming concepts. This unit is the technical core of the course.
Key concepts
- An algorithm is a step-by-step procedure for solving a problem, expressed as sequencing, selection, and iteration.
- Variables store values; lists store ordered collections of values accessible by index.
- Procedures (functions) are reusable blocks of code that can take parameters and return values.
- Simulations use algorithms and random values to model complex real-world phenomena.
Variables, Expressions, and Assignment
A variable is a named container that stores a value. Assignment uses the arrow notation in pseudocode: x <- 5 stores 5 in x. Expressions combine variables, values, and operators to produce results. Arithmetic operators (+, -, *, /, MOD) perform calculations. Boolean operators (AND, OR, NOT) combine true/false values. String operations include concatenation and length. The AP exam uses its own pseudocode language — familiarize yourself with the reference sheet so you can read and trace code fluently.
Control Structures: Selection and Iteration
Selection (IF/ELSE) allows programs to make decisions. The condition is evaluated and different code blocks execute based on whether the result is true or false. Iteration (REPEAT, REPEAT UNTIL) allows programs to execute code multiple times. REPEAT n TIMES runs a block exactly n times. REPEAT UNTIL(condition) runs until the condition becomes true. These structures combine with sequencing (executing statements in order) to form the three building blocks of all algorithms.
Lists and Procedures
A list is an ordered collection of elements accessed by index (1-based in AP pseudocode). Operations include INSERT, APPEND, REMOVE, and accessing by index. Traversing a list with a loop is a fundamental pattern: FOR EACH item IN list processes every element. A procedure is a named block of code that can be called by name, optionally with parameters. Procedures promote code reuse and abstraction — they let you solve a problem once and use the solution many times. The Create Task requires a student-developed procedure with at least one parameter.
AP exam tip
The AP pseudocode reference sheet is available during the exam. Study it beforehand so you can read and trace pseudocode quickly. Remember that list indices start at 1, not 0.
Connections to other units
- Unit 1: Data representation determines how variables store values and how operations work.
- Unit 0: Creative development applies these programming concepts to build complete programs.
- Unit 4: Algorithms run on devices connected through networks, enabling distributed computing.