Question 5
Edexcel Computer Science June 2022 Paper 2GCSE15 marks
On the specification
- 6.2 Program constructs6.3 Data types and structures6.4 Input and output
Question text
5 A program uses a one-dimensional data structure to record the number of kilograms of coffee used each day by the local cafe. The data needs to be saved to a file. Each line of the file represents one week’s worth of coffee consumption. Open file Q05.py Write a program to meet these requirements: • create a comma-separated value text file named Q05_OUTPUT.TXT • write lines to the file, each holding seven weights • process all the weights in the data structure. Here is the expected output file. 3.79,4.16,1.52,3.66,2.58,4.98,4.37 2.95,2.58,4.37,4.59,2.61,6.13,4.49 1.66,2.65,4.64,4.72,3.59,4.56,4.23 2.15,4.03,2.47,4.61,4.55,6.31,5.81 2.63,3.61,3.49,4.49,3.02,3.86,6.26 3.11,1.79,2.62,2.23,2.34,5.66,4.58 3.52,1.53,2.07,3.89,3.48,5.52,6.38 3.77,1.74,1.78,3.87,3.45,3.79,3.36 1.87,2.12,2.09,2.84,2.29,4.46,3.63 Do not add any additional functionality. Use comments, white space, indentation and layout to make the program easier to read and understand. Save your amended code as Q05FINISHED.py (Total for Question 5 = 15 marks)