Calculate Grade¶
The grades of a given course must be calculated from 4 grades: three from partial exams (g1, g2, g3) and the grade from the final exam (gf). The value of any grade is a float value either between 0.0 and 10.0 (both included) or -1.0 if the student did not take the exam.
The grades from the 3 partial exams are used to calculate the Continuous Evaluation Grade (CEG) and the Final Grade (FG).
The CEG is calculated as the average of the two best partial grades (the worst is discarded). However, at least two of them have to be taken by the student, otherwise CEG is 0.0.
The FG is calculated as the maximum of CEG and gf, with the following exceptions:
If none of the 3 partial exams has been taken then FG will be 0.0.
If the final exam has not been taken the FG will be CEG.
Please, implement using Python the function clc_grade() in the module grade (file grade.py) according to the following specification:
clc_grade(g1, g2, g3, gf)
For exemple:
>>> from clc_grade import clc_grade >>> clc_grade(4.5, 5.0, 5.5, 6.0) (5.25, 6.0) >>> clc_grade(3.5, 5.0, 6.5, 4.5) (5.75, 5.8) >>> clc_grade(4.5, 5.5, -1.0, 6.0) (5.0, 6.0) >>> clc_grade(5.5, -1.0, -1.0, 6.0) (0.0, 6.0) >>> clc_grade(-1.0, -1.0, -1.0, 6.0) (0.0, 0.0) >>> clc_grade(3.5, 5.0, 6.5, -1.0) (5.75, 5.8)
Doctests are available at the clc_grade-test.txt file.