Photo AI

Four separate subroutines have been written to control a robot - AQA - GCSE Computer Science - Question 9 - 2021 - Paper 1

Question icon

Question 9

Four-separate-subroutines-have-been-written-to-control-a-robot-AQA-GCSE Computer Science-Question 9-2021-Paper 1.png

Four separate subroutines have been written to control a robot. - Forward(n) moves the robot n squares forward. - TurnLeft(t) turns the robot 90 degrees left. - Tur... show full transcript

Worked Solution & Example Answer:Four separate subroutines have been written to control a robot - 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

The robot moves forward 2 squares:

  1. From its starting position (square with ↑), it moves to square A.
  2. Then it moves to square B.

The path is as follows:

  • Moves from square marked ↑ to square A.
  • Moves from square A to square B.

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

In this program, the robot follows a series of instructions:

  1. The robot checks if there is an object ahead at its starting position (square C).
  2. Since square C is empty, it turns left.
  3. It checks square A, which is also empty.
  4. Then, it turns right twice to face its original direction and moves forward to square C.

The path is as follows:

  • Moves from square with ↑ to square A (empty).
  • Moves from A to B (contains an object).
  • Stops since it can't move forward.

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

;