.. module:: classrooms Classrooms ========== Let's consider the hypothetical scenario of a group of students who have taken a programming exam. The professor responsible of that exam is interested in knowing the pairs of students who got similar grades and were seating next to each other. The information available is the following: - A **grades dictionary**: A :class:`dict` where: - the key is the *Student Id* (:class:`int`) - the value is a :class:`list` with the name (:class:`str`) and the grade (:class:`float`) of that student for that exam. For example: .. literalinclude:: gen_closeL.test :language: python :start-after: --ini-D :end-before: --fi-D - A **class list**: This is a 2-dimension list representing the locations where the students were seating during the exam. More precisely it is a :class:`list` of rows. Each row in turn is a :class:`list` of *Student Ids* (:class:`int`). For example: .. literalinclude:: gen_closeL.test :language: python :start-after: --ini-cl :end-before: --fi-cl Please implement the following Python function in the :mod:`classrooms` module (:file:`classrooms.py` file): .. py:function:: gen_closeL(gradesD, classroomL, eps) such that **given** - ``gradesD``, a :class:`dict` of grades as described above - ``classroomL``, a :class:`list` representing a classroom as described above. It is garanteed that all *Student Id* in this list appear as keys in ``gradesD``. - ``eps``, a :class:`float` value that determines when two grades are similar **returns** a :class:`list` where the elements are also :class:`list` one for each row in ``classroomL``. Each sublist contains a tuple for each pair of students in that row seating next to each other whose grades difference is equal or less than ``eps``. This tuple has 4 components: #. The name of the first student of the pair (the seating on the left side from our point of view). #. The position in the row where he/she was seating. #. The name of the student next to the first one (the seating on the right side from our point of view). #. The absolute value of the difference of their grades. .. note:: Seat positions are counted from left to right starting at 1. For example, the function should behave as follows: .. literalinclude:: gen_closeL.test :language: python :start-after: --ini-ex :end-before: --fi-ex Notice that the second sublist in ``corrL`` is the empty list. That's because 155's grade is not close to 275's and in turn 275's grade is not close to 325's grade. More doctests are available at the :download:`gen_closeL.test ` file.