Question 13

AQA Computer Science June 2023 Paper 1B (8525/1B)GCSE6 marks

On the specification

3.2 Programming
Question text

13 A programmer is writing a game. The game uses a 3 x 3 grid containing nine box squares. Figure 14 A B C 1 2 3 X In the game, a square on the grid is referred to by a letter and a number. For example, square C3 in Figure 14 contains an X. Figure 15 shows part of a Python program that checks the grid reference entered by a player. The grid reference is valid if: • there are exactly two characters • the first character entered is A, B or C • the second character entered is 1, 2 or 3. Figure 15 check = False while check == False: square = "" while len(square) != 2: square = input("Enter grid reference (eg C2): ") square = square.upper() The Python function upper() converts letters into uppercase, eg b1 would be converted to B1 Extend the program from Figure 15 so it completes the other checks needed to make sure a valid grid reference is entered. Your extended program must: • use the variable check • repeat the following steps until a valid grid reference is entered: o get the user to enter a grid reference o output an appropriate message if the grid reference entered is not valid. You should use indentation as appropriate, meaningful variable name(s) and Python syntax in your answer. The answer grid contains vertical lines to help you indent your code. [6 marks] check = False while check == False: square = "" while len(square) != 2: square = input("Enter grid reference (eg C2): ") square = square.upper()