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

Use the variable check

96%

114 rated

Answer

I will declare a variable named check and initialize it to False. This variable will be used to control the loop for valid grid reference input.

Step 2

repeat the input until a valid grid reference is entered

99%

104 rated

Answer

I will construct a while loop that continues as long as check is False. Inside this loop, I will prompt the user to enter a grid reference.

Step 3

get the user to enter a grid reference

96%

101 rated

Answer

Within the loop, I will use input() to ask the user for their grid reference and store it in the variable square. I will then convert square to uppercase using square.upper().

Step 4

output an appropriate message if the grid reference is not valid

98%

120 rated

Answer

I will implement checks using if statements to validate the input format. I will check:

  • if the length of square is not equal to 2, I will print 'Invalid input: must be 2 characters.'
  • if the first character is not in 'ABC', I will print 'Invalid column: must be A, B, or C.'
  • if the second character is not in '123', I will print 'Invalid row: must be 1, 2, or 3.' If all checks pass, I will set check to True.

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

;