←

Paper 2: Application of computational thinking (practice version)

16 marks
The code below should print the average of the scores but contains errors.
def average(values):    total = 0    for i in range(1, len(values)):        total = total + values[i]    return total / len(values) scores = [12, 15, 9, 20]print("Average is " + average(scores))
Identify and correct three errors.
28 marks
Using the data below, write a function clean(readings) that returns a new list without the -999 values, and a function stats(values) that returns the minimum, maximum and mean (rounded to 1 d.p.).
readings = [18.5, 19.2, 21.0, -999, 22.4, 23.1, 20.7, -999, 19.8, 18.9]# -999 means the sensor failed to record a value
315 marks
Write a program that repeatedly asks a user to enter temperature readings (or 'done' to finish), validates each one (must be a number between −50 and 60), stores valid readings, and then outputs: the number of readings, the mean, and how many readings were above the mean. Use at least two functions.
410 marks
Extend your program so that the valid readings are saved to a text file, one per line, and can be loaded again when the program next starts.
512 marks
Without using built-in sort functions, write a function that sorts a list of readings into ascending order using insertion sort, and a function that uses binary search to report whether a given reading is in the sorted list.
68 marks
Write a recursive function that returns the sum of the digits of a positive integer (e.g. 4071 → 12) and explain how the base case prevents infinite recursion.
78 marks
Implement a stack class in Python with push, pop and peek methods and an isEmpty method. pop and peek must handle an empty stack sensibly. Use it to check whether the brackets in a string such as '(a[b]{c})' are balanced.
88 marks
Evaluate the efficiency of your solutions to Questions 3 and 5. Suggest how they could be improved for a data set of 10 million readings.

Finished?

Answer every question to finish (8 left), or finish when the time’s up.

Score 0 / 75 · 0 of 8 marked

This paper is written by Plasmo in the style of the Edexcel A-Level Computer Science exam. It is not a past paper and is not produced or endorsed by the exam board.

Edexcel A-Level Computer Science Mock Exam: Paper 2: Application of computational thinking (practice version) | Plasmo