Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python code plz must upvote data.csv Each sub-question will guide you to complete the process. Use Python code to answer the questions 1-10. Answer the

python code plz
must upvote
image text in transcribed
image text in transcribed
image text in transcribed
data.csv
image text in transcribed
Each sub-question will guide you to complete the process. Use Python code to answer the questions 1-10. Answer the question 11 in English. Hint: You are suggested to read the file 'data. csv' to have a brief idea on the data before coding. print (subject_dict) \{'Biology': [256,939,2348,5243,8234,10454,11169,3741, 'Chemistry': [286,1107,2842,5515,7996,9253, 10078, 441], 'Chinese History': [75,279,692,2033,3518,4798,5179,162],' Chinese Language': [388, 1557, 3867,12705,23818,34976,38794,1025], 'Chinese Literature': [15,64,156,414,756,1025,1114,33], 'Desi gn and Applied Technology': [2, 8, 14, 61, 111, 266, 347, 45], 'Economics': 4200,738,1800,4794, 7021 , 9035 studies': [7,25,62,214,447,601,637,35] ' 'Geography': [92,366,915,2697,4540,6355,70e7,2141, , 'Hea Ith Management and Social' Care': [3, 11, 28, 112, 286, 542, 649, 54], 'History': [59, 261, 623, 2028, 3254, 4 049,4258, erai Studies': 'Information and Communication Technotogy ' 465,1563,3978,14905,27627,36603,39924,813],535,1427,2620,3990,4599,308], 'Lib 198, 226, 235, 10], 'Music': [5, 19, 47, 94, 138, 155, 159, '0], 'Physical Education': [3, 14, 35, 147, 387, 6 49, 826, 84]' 'Physics': [238, 962, 2441, 4390, 6349, 7959, 8610, 209], 'Tourism and Hospitality Studies': [1 5,65,161,546,1155,2366,2830,213], 'Visual Arts': [21,87,218,738,1602,2653,3018,126]} Figure 1: Expected output of the variable 'subject_dict' 2022 HKDSE performance of English Language for Day School Students Performance 5: Performance5Performance5:##:#### Figure 2: Expected final output of the question - A bar chart showing 2022 HKDSE performance of English Language for Day School Students CGTT408s PDS AI 1. (3 marks) Read all the data in the file 'data. csv' into a Python 1 ist named '1ines'. Each element in the 1 ist should correspond to a line (type 'str') in the CSV file. Resources related to file I/O should be handled properly. 2. (2 marks) You will find that the first element in the list "1ines' is the column header of the file 'data. cav'. Remove this eJement from the 1 ist "1ines' and stoce this element in a variable named 'title'. 3. (7 marks) Build a dictionary named 'subject_dict' using the 1 ist '1ines' obtained from question 2. Appropriate data cleaning and preprocessing should be carried out on the list "Iines'. This dictionary shows the mapping between each subject and the corresponding cumulative performance. The expected output is shown in Figure 1. 4. (2 marks) Extract the list showing the number of students' cumulative performance of the subject 'Einglish Language' from 'subject dict'. Stores the result in a variable 'english performance_1.ist'. Note that the numbers indicate the cumulative performance instead of the performance of each category. 5. (4 marks) Perform appropriate calculation, update the list 'eng1ish_performance_1ist' to show the performanoe of English Language for each category instead of showing the camulative performance. The expected output is shown in Figure 3. print(eng tish_perternatce_tiss) [438, 132e, 2909, 2231,13557,18820,18351,3177 ] Figure 3: Expocted final output of the questint 5 - The 'english_performanee_list' shows the performane of Engliah Language for each categiey- 6. (2 marks) Calculate and print the total number of students sat for the English. Language examination using the values in the updated 'english performance_1ist'. Store the results in a variable named 'total_students_english'. 7. (5 marks) Using list comprehension with appropriate calculation, find the performance of English for esch category in percentage (correct to 2 d.p.). Store the result in a variable named 'english_performance_percent'. The expected output is shown in Figure 4. print (enatiahserfornance_persent) [6.65,1.96,4,43,12.2,26.69,27,89,21.6t,4.71] Figure 4: Expected final output of the question 7 - The 'english_performance percent" shwss the performance of Euglish Language for each category in peroentage Page 2 of 3 8. (7 marks) Using the string 'title' obtained in question 2, convert it to a list with only the name of the Performance. The expected output can be seen in Figure 2, which are the label of each bar in the bar chart. 9. (4 marks) Based on the results from previous questions, use the list 'title' and the list 'english_performance_percent' to build a list of tuples showing the mapping between the title (e.g., Performance 5, Performance 5, ) and corresponding number of students in percentage. Name this 1 ist 'english_performance'. 10. (6 marks) Use the percentage obtained in previous steps to print a text-based bar chart. The number of \# printed for each bar is based on the integral value of the percentage plus 1. For example, if the percentage is 0.65, then the number of \# is equal to int (0.65)+1. Hence one \# should be printed. If the percentage is 27.89, then 28 \# should be printed. Write the codes and generate the bar chart. The expected output is shown in Figure 2. 11. (18 marks) Based on all the tasks you have done in this exercise, discuss the followings: (a) (10 marks) Discuss the workflow you have done, from parsing the data to showing the result in a bar chart. You may explain why some of the steps are necessary. (b) (8 marks) Without writing code, discuss how would you modify the code if you are required to display the bar chart that shows the performance of another subject. Subject, Performance 5, Performance 5+, Performance 5+, Performance 4+,Performance - 3+, Performance - 2+, Performance - 1+, Performance - U Biology ,256,939,2348,5243,8234,10454,11169,374 Chemistry, 286,1107,2842,5515,7996,9253,10078,441 Chinese History, 75,279,692,2033,3518,4798,5179,162 Chinese Language, 388,1557,3867,12705,23818,34976,38794,1025 Chinese Literature, 15,64,156,414,756,1025,1114,33 Design and Applied Technology, 2,8,14,61, 111, 266,347,45 Economics, 200,738,1800,4794,7021,9035,9929,484 English Language, 438,1758,4309,11220,21788,32377,37771,3177 Ethics and Religious Studies, 7,25,62,214,447,601,637,35 Geography, 92,366,915,2697,4540,6355,7007,214 Health Management and Social Care, 3,11,28,112,286,542,649,54 History 59,261,623,2028,3254,4049,4258,58 Information and Communication Technology, 58,212,535,1427,2620,3990,4599,308 Liberal Studies, 365,1563,3978,14905,27627,36603,39924,813 Literature in English, 5,19,52,133,198,226,235,10 Music, 5,19,47,94,138,155,159,0 Physical Education, 3,14,35,147,387,649,826,84 Physics, 238,962,2441,4390,6349,7959,8610,209 Tourism and Hospitality Studies, 15,65,161,546,1155,2366,2830,213 Visual Arts, 21,87,218,738,1602,2653,3018,126

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Navigating The Supply Chain Maze A Comprehensive Guide To Optimize Operations And Drive Success

Authors: Michael E Kirshteyn Ph D

1st Edition

B0CPQ2RBYC, 979-8870727585

More Books

Students also viewed these Databases questions