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 or a corresponding block with an arrow. This operation evaluates the given expression and assigns a copy of the resulting value to the variable . To present information to the user, the command 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 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 evaluates specifically to the decimal value . The modulus operator, written as , is used to evaluate the remainder when an integer is divided by a positive integer . The reference sheet assumes that and b > 0. As a specific instance, evaluates to , as five goes into seventeen three times with two remaining. The operator maintains the same precedence level as multiplication () and division ().
Random number generation is handled by the procedure . This command generates and returns a random integer within the range from to , inclusive of both endpoints. Each possible integer result within the specified range is equally likely to occur. For instance, the call can return either , , or .
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 or . The supported relational operators include equality (), inequality (), greater than (a > b), less than (a < b), greater than or equal to (), and less than or equal to (). For example, the statement evaluates to only if the value of is equal to the value of .
Boolean logic is facilitated through three primary operators: , , and . The operator evaluates to if the condition is , and evaluates to if the condition is . The operator evaluates to only if both individual conditions are concurrently ; otherwise, it evaluates to . Finally, evaluates to if either one or both conditions are . It only evaluates to if both conditions are .
Selection Control Structures
Selection statements allow a program to choose different paths of execution based on Boolean conditions. The basic structure evaluates a Boolean expression; if the result is , the code within the designated block of statements is executed. If the condition is , no action is taken within that block. The more complex structure provides an alternative path. If the condition is , the first block of statements executes; otherwise, the second block of statements (following the keyword) is executed.
Iteration and Repetition Patterns
Iteration allows for the repeated execution of a block of code. The command causes a block of statements to execute exactly times. For conditions where the number of repetitions is not predetermined, the structure is used. In this case, the block of statements is repeated continuously until the specified Boolean condition evaluates to .
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 and the length of the list inclusive. If a program attempts to access an index less than or greater than the current length of the list, an error message is triggered and the program terminates. Lists use -based indexing, meaning the first element of a list named is accessed via .
Lists can be initialized or manipulated in several ways. The command creates a new list with values at indices , , and respectively. An empty list is created using . To copy a list, assigns a complete copy of to . For example, if contains the values , then after assignment, will also contain . Elements are accessed using . To move data, assigns the value at index to a variable , while assigns the value of to the list at index . Similarly, copies the value from index to index .
Additional procedures for list modification include , , and . shifts all elements at indices greater than or equal to one position to the right, increases the list length by , and places the new value at index . increases the list length by and adds the value to the very end of the list. deletes the item at index , shifts all subsequent values to the left to fill the gap, and decreases the list length by . The command returns the total number of elements currently in the list. For traversing lists, the structure sequentially assigns each element of the list to the variable , 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 . Parameters act as placeholders for the arguments passed during the call. A procedure is invoked using . Some procedures return a value using the command. The 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 .
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 counterclockwise, and \text{ROTATE_RIGHT}(), which turns it clockwise. Environment sensing is performed via \text{CAN_MOVE}(\text{direction}), which evaluates to 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 , , , and .