Four separate subroutines have been written to control a robot - AQA - GCSE Computer Science - Question 9 - 2021 - Paper 1
Question 9
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
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
The robot moves forward 2 squares:
From its starting position (square with ↑), it moves to square A.
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
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
In this program, the robot follows a series of instructions:
The robot checks if there is an object ahead at its starting position (square C).
Since square C is empty, it turns left.
It checks square A, which is also empty.
Then, it turns right twice to face its original direction and moves forward to square C.