Filter Index Average Grade¶
Given a list of students names and three lists with their grades each list corresponding to one test.
Each position in a list contains the grade of that test for the student whose names is placed in the same position in the names list.
We wish to know the names of the students whose average grade is greater or equal than a given grade threshold.
Students with one or more unknown grades are discarded.
You are required to deliver the following functions in the module fiag (file fiag.py):
The first function is:
- fiag(nameL, cat1L, cat2L, cat3L, t)¶
such that
given
returns a new
listoftuplewith info the position (int) and the name (str) of the students in nameL whose average of the grades in that position in the listscat1L, cat2L, cat3Lis greater or equal thant. The positions are in increasing order. Students with one or more unknown grades (the grade is negative) are discarded from the selection.
For example:
>>> nameL = ['Marc', 'Carla', 'Mat', 'Pau', 'Aina', 'Clara', 'Oriol', 'Júlia'] >>> g1L = [0.0, -1.0, 4.0, 3.25, 5.0, 7.5, 2.5, 9.5] >>> g2L = [-1.0, 7.5, 4.4, 7.5, 5.0, 8.5, 7.5, 9.0] >>> g3L = [-1.0, 5.0, 5.0, 5.25, 5.0, 9.0, 3.5, -1.0] >>> fiag(nameL, g1L, g2L, g3L, 2.0) [(2, 'Mat'), (3, 'Pau'), (4, 'Aina'), (5, 'Clara'), (6, 'Oriol')] >>> fiag(nameL, g1L, g2L, g3L, 5.0) [(3, 'Pau'), (4, 'Aina'), (5, 'Clara')] >>> fiag(nameL, g1L, g2L, g3L, 9.0) []
Notice that students Marc, Carla and Júlia’ have been discarded because at least one grade is unknown.
Doctests are available in the fiag.test file.
The second function is:
- fiag_cl(nameL, cat1L, cat2L, cat3L, t)¶
with the same specification as above but it must be implemented using comprehension lists.
Warning
This function must be implement using comprehension lists.
Doctests are available in the fiag_cl.test file.