.. |SO2| replace:: SO\ :sub:`2` |SO2| levels ============ A nested list of stations contains information on |SO2| levels measured in different stations of air quality. Each sublist corresponds to a station and contains a string with the name of the station and a variable number of *float* values corresponding to the measured |SO2| levels. Some of these values may be negative and denote wrong |SO2| levels that should not be taken into account. For example, the data corresponding to one of such stations could be ``['bcn-34b', 10.3, -1.0, 11.5, 10, 11, 12.1, -2]``, which contains a total of 7 measurements: 5 of them are correct and 2 of them are wrong. It can be assumed that there will always be more than one station in the nested list and that any station sublist will have at least one correct measurement. Save the following functions into the same file :file:`so2_levels.py`. #. Write function :py:func:`average` that takes a list of |SO2| levels corresponding to one station (a sublist of the described nested list without the station name), and returns a *float* with the average of the correct |SO2| levels measured. There will always be at least one correct value. Example: .. literalinclude:: so2_levels_1.txt :language: python3 :lines: 3-11 .. note:: More tests are provided in file :download:`so2_levels_1.txt ` #. Write function :py:func:`same_as_first_average` that takes a nested list of stations as described and a tolerance, ``epsilon``, and returns the number of stations that have the same |SO2| level average as the first station, considering the given tolerance ``epsilon``. As you can see in the examples, we also count the first station. This function must call the previous function :py:func:`average`. .. warning:: Remember that to check the equality between two *float* values ``r1`` and ``r2`` we must not use the operator ``==``. Instead, we must use the given tolerance ``epsilon``: ``abs(r1-r2) < epsilon`` Example: .. literalinclude:: so2_levels_2.txt :language: python3 :lines: 3-15 .. note:: More tests are provided in file :download:`so2_levels_2.txt ` #. Write function :py:func:`under_threshold` that takes a list with the |SO2| levels corresponding to one station (a sublist of the described nested list without the station name) and a *float* value, ``so2``, and returns ``True`` if at least one of the correct values in the given list is strictly below ``so2`` or ``False`` otherwise. Example: .. literalinclude:: so2_levels_3.txt :language: python3 :lines: 3-8 .. note:: More tests are provided in file :download:`so2_levels_3.txt ` #. Write function :py:func:`under_threshold_station` that takes a nested list of stations as described and a *float* value, ``so2``, and returns a string with the name of the first station with an |SO2| level lower than ``so2``. If there is no station that meets this condition, the function will return an empty string. This function must use the previous function :py:func:`under_threshold`. Example: .. literalinclude:: so2_levels_4.txt :language: python3 :lines: 3-15 .. note:: More tests are provided in file :download:`so2_levels_4.txt ` .. rubric:: Solution Solutions are provided in file :download:`so2_levels.py `