AP Computer Science Principles 2026 Exam Reference Notes

General Exam Reference and Administrative Overview

The AP Computer Science Principles 2026 Exam Reference Information serves as a foundational guide for the examination. Students are permitted to use any blank space within the booklet for scratch work throughout the exam period. Proctors are required to collect this reference document at the conclusion of the testing session. All programming concepts and operators provided within this guide are standard across the Computer Science Principles curriculum, ensuring a uniform understanding of syntax and logic for all exam takers.

Variable Assignment, Program Output, and User Input

In the exam's pseudo-code, variable assignment is represented by the text syntax aexpressiona \leftarrow \text{expression} or a corresponding block with an arrow. This operation evaluates the given expression and assigns a copy of the resulting value to the variable aa. To present information to the user, the command DISPLAY(expression)\text{DISPLAY}(\text{expression}) is utilized. This instruction displays the evaluated value of the expression followed by a single space. For interactive programs that require user data, the command INPUT()\text{INPUT}() is used. This function accepts a value from the user and returns that input value for use within the program.

Arithmetic Operators, Order of Operations, and Numeric Procedures

Arithmetic is performed using standard operators: addition (++), subtraction (-), multiplication (*), and division (//). The order of operations established in mathematics applies to the evaluation of all expressions. For example, the expression 17/517 / 5 evaluates specifically to the decimal value 3.43.4. The modulus operator, written as a MOD ba \text{ MOD } b, is used to evaluate the remainder when an integer aa is divided by a positive integer bb. The reference sheet assumes that a0a \geq 0 and b > 0. As a specific instance, 17 MOD 517 \text{ MOD } 5 evaluates to 22, as five goes into seventeen three times with two remaining. The MOD\text{MOD} operator maintains the same precedence level as multiplication (*) and division (//).

Random number generation is handled by the procedure RANDOM(a,b)\text{RANDOM}(a, b). This command generates and returns a random integer within the range from aa to bb, inclusive of both endpoints. Each possible integer result within the specified range is equally likely to occur. For instance, the call RANDOM(1,3)\text{RANDOM}(1, 3) can return either 11, 22, or 33.

Relational and Boolean Logical Operators

Relational operators are used to test the specific relationship between two variables, values, or expressions. These comparisons always result in a Boolean value: either true\text{true} or false\text{false}. The supported relational operators include equality (a=ba = b), inequality (aba \neq b), greater than (a > b), less than (a < b), greater than or equal to (aba \geq b), and less than or equal to (aba \leq b). For example, the statement a=ba = b evaluates to true\text{true} only if the value of aa is equal to the value of bb.

Boolean logic is facilitated through three primary operators: NOT\text{NOT}, AND\text{AND}, and OR\text{OR}. The NOT condition\text{NOT condition} operator evaluates to true\text{true} if the condition is false\text{false}, and evaluates to false\text{false} if the condition is true\text{true}. The condition1 AND condition2\text{condition1 AND condition2} operator evaluates to true\text{true} only if both individual conditions are concurrently true\text{true}; otherwise, it evaluates to false\text{false}. Finally, condition1 OR condition2\text{condition1 OR condition2} evaluates to true\text{true} if either one or both conditions are true\text{true}. It only evaluates to false\text{false} if both conditions are false\text{false}.

Selection Control Structures

Selection statements allow a program to choose different paths of execution based on Boolean conditions. The basic IF(condition)\text{IF}(\text{condition}) structure evaluates a Boolean expression; if the result is true\text{true}, the code within the designated block of statements is executed. If the condition is false\text{false}, no action is taken within that block. The more complex IF(condition){}ELSE{}\text{IF}(\text{condition}) \{\dots\} \text{ELSE} \{\dots\} structure provides an alternative path. If the condition is true\text{true}, the first block of statements executes; otherwise, the second block of statements (following the ELSE\text{ELSE} keyword) is executed.

Iteration and Repetition Patterns

Iteration allows for the repeated execution of a block of code. The command REPEAT n TIMES\text{REPEAT n TIMES} causes a block of statements to execute exactly nn times. For conditions where the number of repetitions is not predetermined, the REPEAT UNTIL(condition)\text{REPEAT UNTIL}(\text{condition}) structure is used. In this case, the block of statements is repeated continuously until the specified Boolean condition evaluates to true\text{true}.

List Operations, Data Manipulation, and Indexing

Lists in this pseudo-code represent ordered collections of data. A critical rule for all list operations is that list indices must be between 11 and the length of the list inclusive. If a program attempts to access an index less than 11 or greater than the current length of the list, an error message is triggered and the program terminates. Lists use 11-based indexing, meaning the first element of a list named aList\text{aList} is accessed via aList[1]\text{aList}[1].

Lists can be initialized or manipulated in several ways. The command aList[value1,value2,value3]\text{aList} \leftarrow [\text{value1}, \text{value2}, \text{value3}] creates a new list with values at indices 11, 22, and 33 respectively. An empty list is created using aList[]\text{aList} \leftarrow []. To copy a list, aListbList\text{aList} \leftarrow \text{bList} assigns a complete copy of bList\text{bList} to aList\text{aList}. For example, if bList\text{bList} contains the values [20,40,60][20, 40, 60], then after assignment, aList\text{aList} will also contain [20,40,60][20, 40, 60]. Elements are accessed using aList[i]\text{aList}[i]. To move data, xaList[i]x \leftarrow \text{aList}[i] assigns the value at index ii to a variable xx, while aList[i]x\text{aList}[i] \leftarrow x assigns the value of xx to the list at index ii. Similarly, aList[i]aList[j]\text{aList}[i] \leftarrow \text{aList}[j] copies the value from index jj to index ii.

Additional procedures for list modification include INSERT\text{INSERT}, APPEND\text{APPEND}, and REMOVE\text{REMOVE}. INSERT(aList,i,value)\text{INSERT}(\text{aList}, i, \text{value}) shifts all elements at indices greater than or equal to ii one position to the right, increases the list length by 11, and places the new value at index ii. APPEND(aList,value)\text{APPEND}(\text{aList}, \text{value}) increases the list length by 11 and adds the value to the very end of the list. REMOVE(aList,i)\text{REMOVE}(\text{aList}, i) deletes the item at index ii, shifts all subsequent values to the left to fill the gap, and decreases the list length by 11. The command LENGTH(aList)\text{LENGTH}(\text{aList}) returns the total number of elements currently in the list. For traversing lists, the FOR EACH item IN aList\text{FOR EACH item IN aList} structure sequentially assigns each element of the list to the variable item\text{item}, from first to last, executing the block of code once for every element.

Procedures and Procedure Calls

Procedures are defined to encapsulate blocks of statements that can be reused. A procedure is defined using PROCEDURE procName(parameter1,parameter2,)\text{PROCEDURE procName}(\text{parameter1}, \text{parameter2}, \dots). Parameters act as placeholders for the arguments passed during the call. A procedure is invoked using procName(arg1,arg2,)\text{procName}(\text{arg1}, \text{arg2}, \dots). Some procedures return a value using the RETURN(expression)\text{RETURN}(\text{expression}) command. The RETURN\text{RETURN} statement immediately terminates the procedure and returns flow of control (and potentially a value) to the calling statement. If a procedure returns a value, it can be assigned to a variable using the syntax resultprocName(arg1,arg2,)\text{result} \leftarrow \text{procName}(\text{arg1}, \text{arg2}, \dots).

Robot Navigation and Environmental Sensing

The Robot section describes commands for controlling a virtual agent within a grid. If the robot attempts to move into a square that is not open or attempts to cross the boundary of the grid, the robot remains in its current position and the program terminates immediately. The \text{MOVE_FORWARD}() command advances the robot one square in the direction it is currently facing. Rotation is handled by \text{ROTATE_LEFT}(), which turns the robot 9090^{\circ} counterclockwise, and \text{ROTATE_RIGHT}(), which turns it 9090^{\circ} clockwise. Environment sensing is performed via \text{CAN_MOVE}(\text{direction}), which evaluates to true\text{true} if there is an open square one unit away in the specified direction relative to the robot's current heading. Valid parameters for direction include left\text{left}, right\text{right}, forward\text{forward}, and backward\text{backward}.