Excellent_marks_2

The marks of several students are saved in a dictionary (dict) where the key is the name of a student and the value is a list of 6 marks (float): the first 5 of them correspond to the marks of 5 subjects of first grade and the 6th value is the average of the marks. We have also tuple with the names of the 5 subjects of first grade (str), in the same order that they appear in all the students lists in the dictionary. Example:

>>> d = {'Joan Pera Pla':[7.0, 8.5, 9.5, 6.0, 9.8, 8.16],
...      'Roser Puig Pi':[9.4, 9.2, 9.5, 9.1, 9.3, 9.3],
...      'Anna Cucurull Alzina':[5.0, 5.0, 5.5, 4.5, 5.0, 5.0],
...      'Pol Riu Mont':[10.0, 8.0, 10.0, 8.0, 9.0, 9.0],
...      'Eric Politja Aviat':[6.0, 7.0, 9.0, 8.0, 10.0, 8.0]}
>>> t = ('Algebra', 'Calculus', 'Programming',
...      'Physics', 'Chemistry')

Write the function cracks() that given a dictionary and a tuple as described and the name of a file (str), creates a file with this name with those students who have excellent marks in the given dictionary. In this file there is a line for each student who has an excellent average mark and there is also a line for each student and subject with an excellent mark. As the data comes from a dictionary, lines in the file will be in the same arbitray order than elements in the given dictionary. A mark is excellent if it is between 9 and 10 (both included). The format of these two types of lines will be:

“The average mark of name_student is mark
“The mark of name_student in name_subject is mark

Examples:

“The average mark of Roser Puig Pi is 9.3”
“The mark of Joan Pera Pla in Programming is 9.5”
“The mark of Joan Pera Pla in Chemistry is 9.8”

Save the function in file cracks.py.

Note

More tests are provided in the test-excellents.txt

Solutions

A solution of these functions is provided in the cracks.py