Scholarship Calculation ======================= The university has decided a new scholarship policy for all 4-year long degrees. The terms of a scholarship for a given student depend on: - The **year** the student is coursing: :class:`int` value. - The student's average **grade**: a :class:`float` value. - Whether the student is **repeating** or not: a :class:`bool` value. - Whether the student's situation is considered to require **special** support or not: a :class:`bool` value. The rules to calculate the scholarship amount are the following: - Any student can apply for a scholarship except those who are either repeating or did not pass (grade lower that 5.0). - Those who qualify will get a so-called fixed **base amount** (:class:`float`) that might be incremented according to the following rules: - The base amount is incremented 25% for students in the 2nd, 3rd and 4th year. - To reward a good academic performance, an additional increment is applied depending on the student's average grade according to the following terms: - Students in their 1st and 4th year who have got the maximum grade (10.0) will receive an additional 25% increment. - For students in their 2nd and 3rd year the criteria to be applied are the following: - If the grade is between 9.0 i 10.0 both included, they get a 20% increment. - If the grade is between 7.0 i 9.0 (7.0 included and 9.0 excluded) then the increment is a 10%. - No extra increment if the grade is lower than 7.0. - Besides that, any student that qualifies as *special* will get and additiontal 50% increment, independently of any previous increment. The data provided to calculate the bill might contain errors. Hence, before calculating the amount, the data must be checked to determine whether is valid or not. If it is not then an **error code** (:class:`int`) must be generated according to the following: - If the base amount is zero or negative then the *hundreds digit* in the error code must be 1. - If the year is not valid (it must be 1, 2, 3 or 4) then the *tens digit* must be 1. - If the grade is not valid (must be between 0.0 and 10.00 included) then the *units digit* must be 1. For example, in case where the base amount is zero and the grade is 11.0 then the error code generated should be 101. If everything is correct then the error code should be 0. See more examples in the doctest of the first function below. You are required to implement the following functions in the :mod:`scholarship` module (file :file:`scholarship.py`): ------------------------------------------------------------------------------------------------------------------------- The first funcion is: .. function:: scholarship_check(base, year, grade, rep, special) such that **given** `base`, `year`, `grade`, `rep` and `special` as specified above. **returns** two values: - a :class:`bool` which value is `True` if there is an error or `False` otherwise. - a :class:`int` with the *error code* as described above (if the previous value is `True`), or 0 otherwise. For example: .. literalinclude:: scholarship_check-test.txt :language: python3 :start-after: --ini :end-before: --fi Additional doctests for validation are available in the :download:`scholarship_check-test.txt` file. ------------------------------------------------------------------------------------------------------------------------- The second funcion is: .. function:: scholarship_eval(base, year, grade, rep, special) such that **given** `base`, `year`, `grade`, `rep` and `special` as specified above and all being valid values, **returns** a :class:`float` with the amount of the scholarship given to that student according to the terms above. For example: .. literalinclude:: scholarship_eval-test.txt :language: python3 :start-after: --ini :end-before: --fi Additional doctests for validation are available in the :download:`scholarship_eval-test.txt` file. ------------------------------------------------------------------------------------------------------------------------- The third (and main) funcion is: .. function:: scholarship_calc(base, year, grade, rep, special) such that **given** `base`, `year`, `grade`, `rep` and `special` as specified above **returns** two values: - a :class:`bool` which value is `True` if there is an error and `False` otherwise. - either the *error code* (:class:`int`) if an error has been found, or the amount of the scholarship given (:class:`float`) calculated according to the terms above otherwise. For example: .. literalinclude:: scholarship_calc-test.txt :language: python3 :start-after: --ini :end-before: --fi Additional doctests for validation are available in the :download:`scholarship_calc-test.txt` file. .. warning:: The implementation of `scholarship_calc` function **must** call the two previous functions.