Question 4

OCR Computer Science June 2022 Computational thinking, algorithms and programming (J277-02)GCSE15 marks

On the specification

(a)
2.3 Producing robust programs
(b)(i)
2.2 Programming fundamentals
(b)(ii)
2.5 Programming languages and IDEs
(c)
2.1 Algorithms2.2 Programming fundamentals
Question text

4 Jack is writing a program to add up some numbers. His first attempt at the program is shown. a = input("Enter a number") b = input("Enter a number") c = input("Enter a number") d = input("Enter a number") e = input("Enter a number") f = (a + b + c + d + e) print(f) (a) Give two ways that the maintainability of this program could be improved. 1 2 [2] (b) Jack’s program uses the addition (+) arithmetic operator. This adds together two numbers. (i) State the purpose of each of the arithmetic operators in the table. Arithmetic operator Purpose * / [2] (ii) Complete the description of programming languages and translators by writing the correct term from the box in each space. continues crashes debugging error executable high-level interpreter language low-level many no one stops with without Jack writes his program in a language. This needs to be translated into assembly or machine code before it can be executed. This is done using a translator. One type of translator is an interpreter. This converts one line of code and then executes it, before moving to the next line. It when an error is found, and when corrected continues running from the same position. This translator is helpful when debugging code. A second type of translator is a compiler. This converts all of the code and produces an error report. The code will not run until there are errors. The file produced can be run the compiler. [5] (c) Jack decides to improve his program. He wants to be able to input how many numbers to add together each time the algorithm runs, and also wants it to calculate and display the average of these numbers. Write an algorithm to: • ask the user to input the quantity of numbers they want to enter and read this value as input • repeatedly take a number as input, until the quantity of numbers the user input has been entered • calculate and output the total of these numbers • calculate and output the average of these numbers. [6] We advise you to spend at least 40 minutes on this section. Some questions require you to respond using either the OCR Exam Reference Language or a high-level programming language you have studied. These are clearly shown.