Coding
Coding
Page 1 of 2
Programming I Week 13
Diploma in CSF / IT / DS / IM / CICTP
Year 1 (2024/25) Semester 1 60 minutes
Instructions
Prior to test
• Create a folder on your desktop with your student id as the name
• Download the data file, “sales.txt”, that you are using in this test to that
folder with the same file name
• Create a python file in that folder with the following naming convention
S12345678.py
[ replace S12345678 with your own student ID ]
• In the file, enter your name, id and group in the first line as comment:
e.g. # John Tan (S12345678) – IT01
Submission
• Submission is to be done in POLITEMall for the actual test, but you are not
required to submit this revision exercise.
PLAGIARISM WARNING:
If a student is found to have submitted work not done by him/her, he/she will
not be awarded any marks for this practical test. Disciplinary action may
also be taken.
Similar action will be taken for student who allows other student(s) to copy
his/her work, or posting any solutions or code related to the practical test
before the end of the hour for the test.
Page 2 of 2
Question 1
An IT company selling Apple products has 2 branches in Singapore. The data file
sales.txt stores the products and the number of units sold for the 2 branches in year
2022.
Sample output:
[['Branch', 'Product', 'Units Sold'], ['Orchard', 'MacBook Air', '205'], ['Orchard',
'MacBook Pro', '89'], ['Orchard', 'iMac', '57'], ['MBS', 'MacBook Air', '28'], ['MBS',
'MacBook Pro', '22']]
(b) Compute and display the total number of units sold for each of the products.
The following shows the required output.
You are required to make use of the following lists in your program.
The total of number of units sold for each of the products are to be computed
and stored in another list:
Total_units_list = [0, 0, 0]