Photo AI

A programmer is writing a game - AQA - GCSE Computer Science - Question 13 - 2023 - Paper 1

Question icon

Question 13

A-programmer-is-writing-a-game-AQA-GCSE Computer Science-Question 13-2023-Paper 1.png

A programmer is writing a game. The game uses a 3 x 3 grid containing nine squares. In the game, a square on the grid is referred to by a letter and a number. For e... show full transcript

Worked Solution & Example Answer:A programmer is writing a game - AQA - GCSE Computer Science - Question 13 - 2023 - Paper 1

Step 1

Extend the program from Figure 15

96%

114 rated

Answer

check = False
while not check:
    square = ""
    while len(square) != 2:
        square = input("Enter grid reference (eg C2): ")
        square = square.upper()

    row = square[1]
    column = square[0]

    if column not in ['A', 'B', 'C']:
        print("Invalid column reference. Please use 'A', 'B', or 'C'.")
    elif row not in ['1', '2', '3']:
        print("Invalid row reference. Please use '1', '2', or '3'.")
    else:
        check = True  # Valid input
        print(f"You have entered a valid grid reference: {square}")

Join the GCSE students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;