Skip to content

Course home

Programming concepts

Programming concepts

EasyMediumHard
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
Question 51

A logistics warehouse uses a grid coordinate system to label its cargo storage bays. The coordinate layout is a 4x4 grid as shown in Figure 1.

Figure 1

ABCD
1
2[Cargo]
3
4

Figure 2

valid = False
while valid == False:
    code = ""
    while len(code) != 2:
        code = input("Enter cargo bay reference (eg A2): ")
        code = code.upper()

Extend the Python program in Figure 2 so that it completes the validation checks 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 (A, B, C, or D)
  • check that the second character of the code is a valid row number (1, 2, 3, or 4)
  • 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