Question 1
AQA Computer Science June 2022 Paper 1B (8525/1B)GCSE6 marks
On the specification
- 1.1
- 3.2 Programming
- 1.2
- 3.1 Fundamentals of algorithms3.2 Programming
- 1.3
- 3.2 Programming
- 1.4
- 3.2 Programming
- 1.5
- 3.2 Programming
- 1.6
- 3.2 Programming
Question text
1 An algorithm, that uses the modulus operator, has been represented using pseudo-code in Figure 1. • Line numbers are included but are not part of the algorithm. Figure 1 1 i USERINPUT 2 IF i MOD 2 = 0 THEN 3 OUTPUT i * i 4 ELSE 5 OUTPUT i 6 ENDIF The modulus operator is used to calculate the remainder after dividing one integer by another. For example: • 14 MOD 3 evaluates to 2 • 24 MOD 5 evaluates to 4 1.1 Shade one lozenge that shows the line number where selection is first used in the algorithm in Figure 1. [1 mark] A Line number 1 B Line number 2 C Line number 3 D Line number 4 1.2 box Shade one lozenge that shows the output from the algorithm in Figure 1 when the user input is 4 [1 mark] A 0 B 2 C 4 D 8 E 16 1.3 Shade one lozenge that shows the line number where assignment is first used in the algorithm in Figure 1. [1 mark] A Line number 1 B Line number 2 C Line number 3 D Line number 4 1.4 Shade one lozenge that shows the line number that contains a relational operator in the algorithm in Figure 1. [1 mark] A Line number 1 B Line number 2 C Line number 3 D Line number 4 Figure 1 has been included again below. Figure 1 1 i USERINPUT 2 IF i MOD 2 = 0 THEN 3 OUTPUT i * i 4 ELSE 5 OUTPUT i 6 ENDIF 1.5 Shade one lozenge to show which of the following is a true statement about the algorithm in Figure 1. [1 mark] A This algorithm uses a Boolean operator. B This algorithm uses a named constant. C This algorithm uses iteration. D This algorithm uses the multiplication operator. 1.6 Figure 2 shows an implementation of the algorithm in Figure 1 using the Python programming language. • Line numbers are included but are not part of the program. Figure 2 1 i = int(input("Enter a number: ")) 2 if i % 2 == 0: 3 print(i * i) 4 else: 5 print(i) The program in Figure 2 needs to be changed so that it repeats five times using definite (count controlled) iteration. Shade one lozenge next to the program that does this correctly. [1 mark] for x in range(0, 5): i = int(input("Enter a number: ")) if i % 2 == 0: A print(i * i) else: print(i) for x in range(0, 6): i = int(input("Enter a number: ")) if i % 2 == 0: B print(i * i) else: print(i) x = 1 while x != 6: i = int(input("Enter a number: ")) if i % 2 == 0: C print(i * i) else: print(i) x = x + 1 x = 6 while x != 0: i = int(input("Enter a number: ")) D if i % 2 == 0: print(i * i) else: print(i) x = x – 1 6