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
- Lsts a non-empty list of students as specified above
- gref is a qualitative grade as specified above
returns
a list with the students in Lsts whose grades are all equal or greater than gref. 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.