Skip to content

Course home

Programming concepts

Programming concepts

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
Question 22

An automated flight system is programmed to control a drone navigating a sequence of waypoints represented as an array called route.

Figure 1: Example route array

Index012345678
Content'R''R'

Figure 2: Flight Rules

  • The drone begins at index 0 of the route array.
  • The goal is to reach the final index of the array (destination).
  • At each turn, the operator is prompted to enter a movement value: 1, 2, or 3.
    • The drone's position is increased by the inputted movement value.
  • If the drone's new position exceeds the final index of the array, or lands on an index containing the restricted character 'R':
    • The message "Restricted airspace!" is displayed.
    • The drone's position is reset to 0.
  • These steps repeat until the drone successfully reaches (or lands exactly on) the final index of the array.

Figure 3: Starting Code

pos = 0
destination = len(route) - 1
while pos < destination:

Extend the program from Figure 3 so that the flight system works as described in the rules in Figure 2.

When writing your program, you should assume:

  • There is an existing array called route.
  • The number of 'R' characters in route can vary.
  • The positions of the 'R' characters in route can vary.
  • The 'R' characters have already been initialized in the array.
  • The route array can be of any length greater than 1.

You should use meaningful variable names and correct programming syntax in your answer.

[8]
Markscheme

Programming concepts Questions

  1. GCSE
  2. /Computer Science
  3. /Programming concepts

298 exam-style questions on AQA GCSE Computer Science Programming concepts. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank