Question 14
AQA Computer Science June 2022 Paper 1B (8525/1B)GCSE12 marks
On the specification
- 14.1
- 3.2 Programming
- 14.2
- 3.2 Programming
Question text
14 A program is being written to simulate a computer science revision game in the style box of bingo. At the beginning of the game a bingo ticket is generated with nine different key terms from computer science in a 3 x 3 grid. An example bingo ticket is provided in Figure 15. Figure 15 CPU ALU Pixel NOT gate Binary LAN Register Cache Protocol The player will then be prompted to answer a series of questions. If an answer matches a key term on the player’s bingo ticket, then the key term will be marked off automatically. 14.1 Figure 16 shows an incomplete Python program to create a bingo ticket for a player. box The programmer has used a two-dimensional array called ticket to represent a bingo ticket. The program uses a subroutine called generateKeyTerm. When called, the subroutine will return a random key term, eg "CPU", "ALU", "NOT gate" etc. Complete the Python program in Figure 16 by filling in the five gaps. • Line numbers are included but are not part of the program. [4 marks] Figure 16 1 ticket = [["","",""], ["","",""], ["","",""]] 2 i = 0 3 while i < 3: 4 j = 5 while j < 3: 6 ticket[ ][ ] = generateKeyTerm() 7 8 14.2 Each time a player answers a question correctly the ticket array is box updated; if their answer is in the ticket array then it is replaced with an asterisk (*). An example of the ticket array containing key terms and asterisks is shown in Figure 17. Figure 17 1 2 0 CPU ALU * 1 * * LAN 2 Register Cache * Write a subroutine in Python called checkWinner that will count the number of asterisks. The subroutine should: • take the ticket array as a parameter • count the number of asterisks in the ticket array • output the word Bingo if there are nine asterisks in the array • output the total number of asterisks if there are fewer than nine asterisks in the array. You must write your own count routine and not use any built-in count function that might be available in Python. You should use indentation as appropriate, meaningful variable name(s) and Python syntax in your answer. The answer grid below contains vertical lines to help you indent your code. [8 marks]