Student Grades¶
We consider an scenario (that should be familiar to you) of students, sujects they are taking and grades obtained from various evaluation activities.
We have a file with information about the grades (which is not fixed) of the students of a certain group in a certain subject. The specific format this Grades File is as follows:
The file grades_11_PRG_2526.csv is an example:
SIN,GRADES ========== 8156,2.5,5.9,4.8,5.3 2345,3.0,9.6,5.3,7.7,10.0 3112,4.5,7.0,5.7,3.2,4.5,8.8 4343,0.0,3.3,5.2,7.5 9876,5.0,4.3,7.2,7.5,9.0
In this exam you are required to deliver two different functions in separate files both taking a Grades File as primary input.
Firstly, given a grades file we need to produce a file with those students whose average is equal or higher than a given threshold. The average grade is computed by discarding the lowest grade and applying the standard formula.
The format of the resulting Average Grades File corresponding to a given Grades File f and a threshold value grade_th should be as follows:
For example
7.0_avg_grades_11_PRG_2526.csv.
- The header: It has to lines:
The words
'IDN,AVG,GRADES'.A line of
'='with the same lenght.
- The lines: Each line of the file has the informations corresponding to a student, separated by coma (
','):
The file 7.0_avg_grades_11_PRG_2526.csv is an example:
IDN,AVG,N_G,GRADES ==================== 2345,8.15,4,9.6,5.3,7.7,10.0 9876,7.17,4,5.0,7.2,7.5,9.0
To this purpose you are required to delivered he following function in the module std_filter (file std_filter.py):
- std_filter(grades_filename, grade_th)¶
such that
given
does two things:
writes the Average Grade File corresponding to the grades_filename file as described above resulting from filtering the student whose average grade is equal or higher than the
grade_thvalue. Bear in mind that:
The name of this file must be as described in the average grades file format description above.
The lowest grade is discarded before computing the average.
In case that student passes the threshold, the discarded grade shoud not be included in the grades list.
returns:
For example the call std_filter('grades_11_PRG_2526.csv', 7.0)
should return (5, 2) and write a file called 7.0_avg_grades_11_PRG_2526.csv with the following info:
IDN,AVG,N_G,GRADES ==================== 2345,8.15,4,9.6,5.3,7.7,10.0 9876,7.17,4,5.0,7.2,7.5,9.0
Find the doctest file at std_filter_test.txt and all necessary files are available at the following compressed file: std_filter_test_files.zip.
Secondly, given a Grades File we need to update the information in the Academic Record which has the information of the grades for a number of students. For each student, we have personal information and the average grades of the various subjects the student is enroled in. See a very mall example of that in the file AR_2526.csv:
IDN,NAME,GROUP,SUBJECTS ======================= 8156,Aina Vilaplana Puig,11,ALG,4.55,CLC,5.9,FSC,4.8,QMC,7.5 2345,Marc Vila Garcia,11,ALG,3.10,CLC,6.6,FSC,5.3,QMC,5.9 3112,Roc Vila Valls,11,ALG,4.5,CLC,7.0,FSC,5.7,QMC,4.75 4343,Ona Sala Majó,11,ALG,0.0,CLC,3.35,FSC,5.25,QMC,7.5 1234,Pol Vilar Sala,11,ALG,5.0,CLC,5.3,FSC,7.25,QMC,8.5
Specificly, the format of an Academic Record File is as follows:
The file can be anything.
- The lines: Each line (for example
8156,Aina Vilaplana Puig,11,ALG,4.5,CLC,5.9,FSC,4.8,QMC,7.5) has the informations of one student, separated by coma (','):
The purpose of this function is to incorporate the average grades fo a subject for a number of students (provided in a Grade Files as described above). To this purpose you are required to deliver the following function in the module std_update (file std_update.py):
- std_update(grades_filename, ar_filename)¶
such that
given
does two things:
updates the
ar_filenamefile by adding the subject and the average grade fromgrades_filenameat the end of each student inar_filename. Grades of students ingrades_filenamefile not found in thear_filenamefile will not be included. Bear in mind that:
You can get the subject name from the graes filename (see the filename specification in the Grades format). - The average grade must be calculated like in the previous function.
returns:
For example, considering the file grade file grades_12_PRG_2526.csv:
SIN,GRADES ========== 8156,2.5,5.9,4.8,5.3,10.0 2233,3.0,9.6,5.3,7.7,4.5,8.8 3112,4.5,7.0,5.7,3.2 4431,0.0,3.3,5.2,7.5,6,5 1234,5.0,4.3,7.2,7.5,9.0
and the Academic Record above AR_2526.csv:
IDN,NAME,GROUP,SUBJECTS ======================= 8156,Aina Vilaplana Puig,11,ALG,4.55,CLC,5.9,FSC,4.8,QMC,7.5 2345,Marc Vila Garcia,11,ALG,3.10,CLC,6.6,FSC,5.3,QMC,5.9 3112,Roc Vila Valls,11,ALG,4.5,CLC,7.0,FSC,5.7,QMC,4.75 4343,Ona Sala Majó,11,ALG,0.0,CLC,3.35,FSC,5.25,QMC,7.5 1234,Pol Vilar Sala,11,ALG,5.0,CLC,5.3,FSC,7.25,QMC,8.5
the call std_update('grades_12_PRG_2526.csv', 'AR_2526.csv') should return (5, 3, ['2233', '4431']) and rewrite the AR_2526.csv, let’s call it AR_2526_12.ref, with the following info:
IDN,NAME,GROUP,SUBJECTS ======================= 8156,Aina Vilaplana Puig,11,ALG,4.55,CLC,5.9,FSC,4.8,QMC,7.5,PRG,6.5 2345,Marc Vila Garcia,11,ALG,3.10,CLC,6.6,FSC,5.3,QMC,5.9 3112,Roc Vila Valls,11,ALG,4.5,CLC,7.0,FSC,5.7,QMC,4.75,PRG,5.73 4343,Ona Sala Majó,11,ALG,0.0,CLC,3.35,FSC,5.25,QMC,7.5 1234,Pol Vilar Sala,11,ALG,5.0,CLC,5.3,FSC,7.25,QMC,8.5,PRG,7.17
Doctests are available at the std_update_test.txt file and the files necessary to pass those tests are available at the following compressed file: AR_2526.zip.
Note
Using a dictionnary to keep the data coming form the Academic Record is recommended.