AP CSP Exam Reference Sheet
AP CSP Exam Reference Sheet
AP CSP Exam Reference Sheet
CapstoneScience
AP Computer ProgramPrinciples Exam Reference Sheet Course and Exam Description
Instruction Explanation
Assignment, Display, and Input
Text: Evaluates expression and assigns the
a ← expression result to the variable a.
Block:
Instruction Explanation
Relational and Boolean Operators (continued)
Text: Evaluates to true if condition is false;
NOT condition otherwise evaluates to false.
Block:
Selection
Text: The code in block of statements
IF (condition) is executed if the Boolean expression
{ condition evaluates to true; no action is
<block of statements> taken if condition evaluates to false.
}
Block:
Instruction Explanation
Selection (continued)
Text: The code in first block of
IF (condition) statements is executed if the Boolean
{ expression condition evaluates to true;
<first block of statements> otherwise, the code in second block of
} statements is executed.
ELSE
{
<second block of statements>
}
Block:
Iteration
Text: The code in block of statements is
REPEAT n TIMES executed n times.
{
<block of statements>
}
Block:
Instruction Explanation
List Operations
For all list operations, if a list index is less than 1 or greater than the length of the list, an error
message is produced and the program terminates.
Text: Refers to the element of list at index i.
list[i] The first element of list is at index 1.
Block:
Instruction Explanation
List Operations (continued)
Text: Removes the item at index i in list and
REMOVE (list, i) shifts to the left any values at indices greater
Block: than i. The length of list is decreased by 1.
Procedures
Text: A procedure, name, takes zero or more
PROCEDURE name (parameter1, parameters. The procedure contains
parameter2, ...) programming instructions.
{
<instructions>
}
Block:
Instruction Explanation
Robot
If the robot attempts to move to a square that is not open or is beyond the edge of the grid, the robot
will stay in its current location and the program will terminate.
Text: The robot moves one square forward in the
MOVE_FORWARD () direction it is facing.
Block: