Photo AI

Draw the path of the robot through the grid below if the following program is executed (the robot starts in the square marked by the ↑ facing in the direction of the arrow) - AQA - GCSE Computer Science - Question 9 - 2021 - Paper 1

Question icon

Question 9

Draw-the-path-of-the-robot-through-the-grid-below-if-the-following-program-is-executed-(the-robot-starts-in-the-square-marked-by-the-↑-facing-in-the-direction-of-the-arrow)-AQA-GCSE Computer Science-Question 9-2021-Paper 1.png

Draw the path of the robot through the grid below if the following program is executed (the robot starts in the square marked by the ↑ facing in the direction of the... show full transcript

Worked Solution & Example Answer:Draw the path of the robot through the grid below if the following program is executed (the robot starts in the square marked by the ↑ facing in the direction of the arrow) - AQA - GCSE Computer Science - Question 9 - 2021 - Paper 1

Step 1

1. Draw the path of the robot through the grid below if the following program is executed (the robot starts in the square marked by the ↑ facing in the direction of the arrow).

96%

114 rated

Answer

The robot starts at position (2,3) facing up. Following the commands:

  1. Forward(2): Moves to (0,3) [Square A].
  2. TurnLeft(): Now facing left (West).
  3. Forward(1): Moves to (0,2) [Square B].
  4. TurnRight(): Now facing up (North).
  5. Forward(1): Moves to (0,1) [Square C].

The path is drawn through squares A, B, and C.

Step 2

2. Draw the path of the robot through the grid below if the following program is executed (the robot starts in the square marked by the ↑ facing in the direction of the arrow). If a square is black then it contains an object.

99%

104 rated

Answer

In this scenario, the robot starts at position (2,3):

  1. ObjectAhead(): The square (1,3) is empty, so the robot moves ahead.
  2. TurnLeft(): Now facing left (West).
  3. In the next iteration, ObjectAhead(): Square (1,3) is checked, robot turns left if found. As it is empty, it checks again to turn right and left subsequently.
  4. It will continue until the path downwards is reached getting stuck at the black squares at positions (1,3) and (2,2).
  5. Final movement goes down to (2,1) and then ends up at (2,0).

Join the GCSE students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;