Answered step by step
Verified Expert Solution
Question
1 Approved Answer
python/jupyter code please Q2: New Student Grades - 30 pts Recall the Student Grades question from Midterm 6. Here, you will solve similar question but
python/jupyter code please
Q2: New Student Grades - 30 pts Recall the "Student Grades" question from Midterm 6. Here, you will solve similar question but without numpy. Instead, you will use lists, dictionaries, tuples, etc. so that you can refresh your knowledge of these topics. You have to change the function header according to the following: o By default, each midterm weight is 0.15, each homework weight is 0.05, final exam weight is 0.3, lab weight is 0.1 (total is 1) If the user does not specify any weights when calling the function, the default weights listed above should be used. If the user specifies different weights when calling the function, the function should use the user-specified weights. cumulative_grades calculates each student's cumulative course grade according to the weights. Return value of cumulative_grades is a dictionary: key is studentID (string), value is the cumulative course grade of the student (float) o Consider the following file: new_student grades.csv. . {"692095': 59.2515, 385818': 56.038, 862060': 55.987500000000004, 373605': 56.7145, studentID,midi, hwl, mid2, hw2, mid3, hw3, final, lab 692095,24.26,27.11, 70.51,76.18,83.61,77.08, 47.83,91.27 385818,48.99,43.12,65.96, 62.78,36.47,38.64,55.97,93.07 862060,84.63,81.06,65.27,67.31, 32.32,27.78, 35.60,91.67 373605, 69.64,54.65,50.57,50.37,41.95, 30.99,54.96,91.02 112675, 69.85,71.92,62.87,64.97,50.32, 20.81, 35.03,88.94 947445, 70.74,70.81,83.51,82.72,0.00,0.00,65.44,88.11 617065, 86.98,87.88,24.48,20.61,13.68,26.59,59.40,91.33 349782,62.00, 71.02, 30.21, 35.46,42.37,49.04,40.20, 92.06 138333, 48.03,31.20,48.13,52.65, 82.19,100.00,75.26,91.52 . Part D: Write a function called passing_students(dic, threshold) such that: dic is the dictionary created in Part C. threshold is a float value corresponding to the passing grade of the course. passing students returns a list of studentIDs (a list of strings) corresponding to the students who passed the course. Students who passed the course are those whose cumulative grade is higher than threshold. The first line contains the headers of the table: studentiD is the 6-digit university ID of the student, mid1 is Midterm 1, hw1 is Homework 1, mid2 is Midterm 2, and so forth. final is the final exam grade, lab is the lab grade. Then, each remaining line in the csv file corresponds to the grades of one student separated by commas. You may assume that there are no errors in the file, e.g., no erroneous or empty grades, all grades are legitimate (between 0 and 100). . Part E: Write a function called write_to_file(dic, threshold) such that: dic is the dictionary created in Part C. threshold is a float value corresponding to the passing grade of the course. write_to_file should write ONE LINE PER STUDENT to a file called "results.txt": If the student passed the course, the line should be in the format: Student: **1234, course average: 73.921, PASSED If the student failed the course, the line should be in the format: Student: **1234, course average: 26.308, FAILED o Open NewStudentGrades.ipynb and implement the following functions. Part A: Write a function called read_data(filename) such that: filename is the name of the file that should be read, e.g., "new_student grades.csv" read_data returns a list of tuples where each tuple corresponds to one student. Tuple content should be in the same order as in the file, i.e. (studenti, mid1, hw1, mid2, hw2, mid3, hw3, final, lab) students should be string, rest should be floats. Notice that: The first two digits of the student ID are replaced by asterisks (**) to preserve anonymity, only the last 4 digits are printed. Course average contains two digits before the decimal point, three digits after the decimal point. The string "PASSED" or "FAILED" is written at the end according to whether the student's average is above or below the threshold. (492095, 24.26. 27.11, 70.51, 76.18. 13.61, 77.06. 47.03. 91.27). "385818', 48.99. 43.12. 65.96, 62.78. 36.47, 38.64.5 5.97, 93.07). "842060, 84.63, 01.06, 65.27, 67.31, 32.32, 27.78, 35.6. 91.67), (*373605, 49.64, 54.6, 50.57, 50.37, 41. 95, 30.99. 54.96. 91.02). (112675, 49.85. 71.92. (2.07. 64.97. 50.32. 20.01. 35.03. 88.94). 947445, 70.74. 70.81, 83.5 1. 82.72. 0.0.0.0, 65.44, 88.11), ('617065, 86.98, 87.88. 24.48. 20.61, 15.68, 26.59, 59.4. 91.33), 349782", 62.0, 71.0 Part B: Write a function called midterm_averages(data) such that: data is the list of tuples constructed in Part A. midterm_averages has 3 return values in the following order: mid1_grade_avg, mid2_grade_avg, mid3_grade_avg Part F: Write a function called sort_students(dic) such that: dic is the dictionary created in Part C. sort_students returns a list of student IDs (only the student IDs) sorted in DESCENDING order of their cumulative grades. . Part C: Write a function called cumulative_grades(data, mt_weight, hw_weight, final_weight, lab_weight) such that: data is the list of tuples constructed in Part AStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started