←

Paper 2: Application of computational thinking

1(a)4 marks
The program below should output 'Pass' if the average of three scores is 50 or more. It contains a syntax error and a logic error.
score1 = int(input("Score 1: "))score2 = int(input("Score 2: "))score3 = int(input("Score 3: "))average = score1 + score2 + score3 / 3if average >= 50    print("Pass")else:    print("Fail")
Identify and correct both errors.
1(b)6 marks
Extend the corrected program so that each score must be between 0 and 100; the user is asked again until a valid score is entered. Answer in Python. (In the real exam you edit provided code files on screen; here, type your program.)
210 marks
Write a program that: asks the user for a sentence; outputs the number of words; outputs the longest word (if two are equally long, output the first); outputs the sentence with the first letter of each word in upper case. Answer in Python. (In the real exam you edit provided code files on screen; here, type your program.)
312 marks
A list stores daily temperatures: temps = [14.2, 17.8, 12.5, 19.1, 16.0, 13.4, 18.3] and days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']. Write a program that outputs: the highest temperature and its day; the lowest temperature and its day; the mean rounded to 1 decimal place; the days with a temperature above the mean. Do not use the built-in max(), min() or sum() functions. Answer in Python. (In the real exam you edit provided code files on screen; here, type your program.)
413 marks
A text file members.txt stores one member per line in the format name,age,type, e.g. Ola,15,junior. Write a program that: reads the file; counts the members of each type (junior, adult, senior); outputs the counts; writes the names of all junior members aged 14 or over to a new file called squad.txt, one per line. Answer in Python. (In the real exam you edit provided code files on screen; here, type your program.)
515 marks
A noughts and crosses board is stored as a 2D list, e.g. board = [['X', 'O', 'X'], [' ', 'X', 'O'], ['O', ' ', 'X']]. Write a function check_winner(board) that returns 'X' or 'O' if that player has three in a row (row, column or diagonal), 'Draw' if the board is full with no winner, or 'None' otherwise. Write code that calls the function with the example board and outputs the result. Answer in Python. (In the real exam you edit provided code files on screen; here, type your program.)
615 marks
A school shop sells: pen £0.80, ruler £1.20, calculator £8.50, pad £2.00. Store the prices in a dictionary. Write a program that: shows a menu of items; lets the user add items and quantities to a basket until they type 'done'; rejects items not on the menu and quantities that are not whole numbers from 1 to 20; outputs an itemised receipt with line totals; applies a 10% discount if the total is over £20; outputs the final total formatted to 2 decimal places. Answer in Python. (In the real exam you edit provided code files on screen; here, type your program.)

Finished?

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

Score 0 / 75 · 0 of 7 marked

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

Edexcel GCSE Computer Science Mock Exam: Paper 2: Application of computational thinking | Plasmo