← AP CSP

Robot grid: AP CSP practice

The robot commands on the reference sheet. 3 questions in the style of the AP CSP exam.

Sample questions

A robot is on a 5 by 5 grid. Columns are numbered 1 to 5 from left to right and rows 1 to 5 from bottom to top. All squares are open. The robot starts in column 1, row 1, facing up (toward row 5). Where is the robot, and which way does it face, after this code segment runs?

REPEAT 2 TIMES
{
   MOVE_FORWARD()
   MOVE_FORWARD()
   ROTATE_RIGHT()
}
  1. Column 3, row 1, facing left
  2. Column 3, row 3, facing down
  3. Column 3, row 3, facing right
  4. Column 1, row 3, facing up