Question 4
AQA Computer Science June 2022 Paper 1B (8525/1B)GCSE3 marks
On the specification
- 4.1
- 3.1 Fundamentals of algorithms
- 4.2
- 3.1 Fundamentals of algorithms
Question text
4 The two Python programs in Figure 5 output the value that is equivalent to adding box together the integers between 1 and an integer entered by the user. For example, if the user entered the integer 5, both programs would output 15 Figure 5 Program A print("Enter a number: ") num = int(input()) total = 0 for i in range(1, num + 1): total = total + i print(total) Program B print("Enter a number: ") num1 = int(input()) num2 = num1 + 1 num2 = num1 * num2 num2 = num2 // 2 print(num2) 4.1 Shade one lozenge to indicate which of the statements is true about the programs in Figure 5. [1 mark] A Both programs are equally efficient. B Program A is more efficient than Program B. C Program B is more efficient than Program A. 4.2 Justify your answer for Question 04.1. [2 marks]