Progress

The progress and final grade of a student must be calculated from the grades of 3 exams.

  1. The progress is a string with the following possible values:

    • constant if all grades are equal.

    • positive if every grade is greater or equal than the previous one (and is not constant).

    • negative if every grade is less or equan than the previous one (and is not constant).

    • peak if the second grade is greater than the other two.

    • valley if second grade is less than the other two.

  2. The average is calculated as the average of the two best partial grades (the worst is discarded) except if the progress is negative where no grade will be discarded.

If any of the 3 given grades is not between 0.0 and 10.0 included, then will consider that an error happened. In this case, no matter what, the progress must be error and the average -1.0.

Please, implement the following Python function in the module progress (file progress.py) according to the following specification:

progress(g1, g2, g3)
takes
g1, g2, g3 float values
returns 2 values:
- a str corresponding to the grades progress as specified above
- a float corresponding to grades average as specified above and rounded to 1 decimal.

Exemples:

>>> progress(-1.0, 0.0, 5.0)
('error', -1.0)
>>> progress(5.0, 7.5, 9.5)
('positive', 8.5)
>>> progress(5.0, 5.0, 3.0)
('negative', 4.3)

Doctests are available at the progress-test.txt file.