Filter Students¶
Consider a list of students where each student is represented by a list with two components: a DNI without letter (int) and a list of grades in qualitative form, thus a grade is a str formed by a letter A, B, C or D possibly followed by a + or -. The order in decreasing value of qualitative grades is as follows: A+, A, A-. B+, … , D, D-.
For example:
[[77888999, ['B','A+','C-']], [22333444, ['B-','B+','A+']], [11222333, ['B','A','B+']]]
Implement the following Python function in the module filter_sts (file filter_sts.py):
filter_sts(Lsts, gref) takes-Lstsa non-empty list of students as specified above-grefis a qualitative grade as specified abovereturnsa list with the students inLstswhose grades are all equal or greater thangref. The list must be increasingly ordered by the DNI.
Exemples:
>>> L = [[77888999, ['B','A+','C-']], [22333444, ['B-','B+','A+']], [11222333, ['B','A','B+']]] >>> Lsol = filter_sts(L, 'B-') >>> Lsol == [ [11222333, ['B','A','B+']], [22333444, ['B-','B+','A+']] ] True >>> Lsol = filter_sts(L, 'B') >>> Lsol == [ [11222333, ['B','A','B+']] ] True >>> Lsol = filter_sts(L, 'B+') >>> Lsol == [ ] True
Note
To do this function you can, but is not mandatory, import and use the leq_qual(g1, g2) function provided in the module qgrades.py. Check the function code to is it useful for.
Doctests are available at the filter_sts-test.txt file.