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

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

  1. Initial Position: The robot starts at the square denoted by the ↑, facing upwards.
  2. Execute Forward(2): The robot moves up 2 squares:
    • From (1, 1) to (0, 1) then to moving beyond the grid limit at (-1, 1). The path is drawn up to (0, 1).
  3. Execute TurnLeft(): The robot turns left to face west.
  4. Execute Forward(1): The robot moves left to (0, 0).
  5. Execute TurnRight(): The robot turns right to face north again.
  6. Execute Forward(1): The robot moves back up to (1, 0).

Final Path:

  • The path on the grid can be depicted as follows:
1 .  .  .  .  .  
 .  .  .  .  .  
→  .  .  .  .  

Where the robot's journey is marked on the grid.

Step 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

  1. Initial Position: The robot starts at the square denoted by the ↑. Let's assume the position coordinates (1, 1).
  2. Execute WHILE ObjectAhead() = true: Start the loop if there is an object straight ahead (upward).
  3. Execute TurnLeft(): If there is an object ahead, the robot turns left (now facing west).
  4. Execute IF ObjectAhead() = true THEN: Check if there is an object ahead:
    • If yes, it then executes TurnRight() (turns from west to north).
    • It executes another TurnRight() (now facing east).
  5. Execute ENDIF: Finalizing conditions and actions.
  6. Execute Forward(1): Moves to the east (if open).
  7. Execute ENDWHILE: Returns to checking condition for the loop again.
  8. Execute Forward(1): Finally, moves one square forward.

Final Path:

  • The path on the grid can be depicted as follows:
   .  .  .  .  .  
 .  .  X  .  .  
.  .   ↑   .  .  

Where 'X' denotes a square with an object the robot encounters.

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

;