Pensions ======== The expenses of a group of pensioners are stored in a list of sublists where each sublist represents a pensioner's data and it consists of the identifier (ID) of the pensioner (string), an integer that indicates the age and some recorded monthly expenses (integers). In the following example, the first sublist stands for a pensioner with ID '1111A' who is 68 years old and three monthly expenses of 640, 589 and 573. .. code:: python [['1111A', 68, 640, 589, 573], ['2222D', 69, 710, 550, 570, 698, 645, 512]] Save all functions into the same file named :file:`pensions.py`. #. Write the function :py:func:`expense_average` that given a list of pensioners returns another list with the average monthly expense of each pensioner. The list must be sorted increasingly. .. literalinclude:: pensions1.txt :language: python3 :lines: 3- .. note:: More tests are provided in file :download:`pensions1.txt`. #. Write the function :py:func:`exp_averag_sup` that takes a list of pensioners and an expense, ``d`` (float), and returns another list with two elements: ID and age of the first pensioner that has an average expense greater than ``d``. If there is any such pensioner, the function must return an empty list. .. literalinclude:: pensions2.txt :language: python3 :lines: 3- .. note:: More tests are provided in file :download:`pensions2.txt`. #. Write the function :py:func:`exp_sup` that takes a list of pensioners and an expense, ``d`` (float), and returns another list with the ID of those pensioners with one or more of their monthly expenses superior to ``d``. IDs in the new list must appear in the same order than in the original list. If there are any such pensioners, the function must return an empty list. .. literalinclude:: pensions3.txt :language: python3 :lines: 3- .. note:: More tests are provided in file :download:`pensions3.txt`. #. Write the function :py:func:`no_reach` that takes a list of pensioners and an expense, ``d`` (float), and returns the ID of the first pensioner that has an expense superior to ``d``. If there is any such pensioner, the function must return an empty string. .. literalinclude:: pensions4.txt :language: python3 :lines: 3- .. note:: More tests are provided in file :download:`pensions4.txt`. #. Write the modifier function :py:func:`put_average` that given a list of pensioners, modifies this list adding at the end of each sublist the average expense. .. literalinclude:: pensions5.txt :language: python3 :lines: 3- .. note:: More tests are provided in file :download:`pensions5.txt`. .. rubric:: Solution A solution of these functions is provided in file :download:`pensions.py `