Skip to content

Course home

Programming concepts

Programming concepts

EasyMediumHard
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
Question 44

An autonomous marine research buoy network uses a grid coordinate system to track its deployment stations. The station layout is a 3x5 grid as shown in Figure 1.

Figure 1

XYZ
5
6[Buoy]
7
8
9

Figure 2

valid = False
while valid == False:
    ref = ""
    while len(ref) != 2:
        ref = input("Enter buoy station reference (e.g. Y6): ")
        ref = ref.upper()

Extend the Python program in Figure 2 so that it completes the validation checks and matches the coordinate layout in Figure 1.

Your extended program must:

  • use the variable valid
  • check that the first character of the code is a valid column letter (X, Y, or Z)
  • check that the second character of the code is a valid row number (5, 6, 7, 8, or 9)
  • change the value of valid to True if both checks are met
  • output an appropriate error message if any part of the coordinate code is invalid.

You should write Python code or precise pseudocode in your answer.

[6]
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