1/24
Comprehensive vocabulary flashcards covering the AP Computer Science Principles Exam Reference Sheet, including operators, selection, lists, procedures, and robot commands.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
a ← expression
Evaluates expression and then assigns a copy of the result to the variable a.
DISPLAY(expression)
Displays the value of expression, followed by a space.
INPUT()
Accepts a value from the user and returns the input value.
a / b
The arithmetic operator used to perform division on a and b. For example, 17/5 evaluates to 3.4.
a MOD b
Evaluates to the remainder when a is divided by b. Assume a is an integer ≥0 and b is an integer > 0. For example, 17 MOD 5 evaluates to 2.
RANDOM(a, b)
Generates and returns a random integer from a to b, including a and b, where each result is equally likely to occur.
Relational Operators
The symbols =, =, >, <, ≥, and ≤ used to test the relationship between two variables, expressions, or values, evaluating to a Boolean value.
NOT condition
Evaluates to true if condition is false; otherwise evaluates to false.
condition1 AND condition2
Evaluates to true if both condition1 and condition2 are true; otherwise evaluates to false.
condition1 OR condition2
Evaluates to true if condition1 is true or if condition2 is true or if both are true; otherwise evaluates to false.
IF(condition)
A selection statement where the code in the block of statements is executed only if the Boolean expression condition evaluates to true.
REPEAT n TIMES
An iteration structure where the code in the block of statements is executed exactly n times.
REPEAT UNTIL(condition)
An iteration structure where the code in the block of statements is repeated until the Boolean expression condition evaluates to true.
List Indexing
The first element of a list is at index 1; if an index is less than 1 or greater than the length of the list, an error message is produced and the program terminates.
aList[i]
Accesses the element of aList at index i.
INSERT(aList, i, value)
Any values in aList at indices greater than or equal to i are shifted one position to the right, the length increases by 1, and value is placed at index i.
APPEND(aList, value)
The length of aList is increased by 1, and value is placed at the end of aList.
REMOVE(aList, i)
Removes the item at index i in aList and shifts to the left any values at indices greater than i, decreasing the length of aList by 1.
LENGTH(aList)
Evaluates to the number of elements in aList.
FOR EACH item IN aList
The variable item is assigned the value of each element of aList sequentially from first to last, executing the block of statements once for each assignment.
PROCEDURE procName(parameter1, parameter2, …)
Defines a procedure that takes zero or more arguments and contains a block of statements.
RETURN(expression)
Returns the flow of control to the point where the procedure was called and returns the value of expression; causes an immediate return from the procedure.
MOVE_FORWARD()
The robot moves one square forward in the direction it is facing; if the square is not open or beyond the edge, the program terminates.
ROTATE_LEFT()
The robot rotates in place 90 degrees counterclockwise.
CAN_MOVE(direction)
Evaluates to true if there is an open square one square in the direction (left, right, forward, or backward) relative to where the robot is facing.