Bus3 ==== Consider a dictionary (:class:`dict`) with information about the passengers of an interurban bus. Let's call it the *passengers dictionary* (:class:`psgD`) where the *keys* are passenger identifiers, each composed of a 2-component :class:`tuple` with following passenger's info: - the id number (:class:`str`) - the name (:class:`str`) composed of two words separated by ``' '``. The *value* associated to each passenger is a 4-component :class:`list` with information about the passenger's trip: - the town of origin (:class:`srt`) - the town of destination or *stop* (:class:`srt`) - the row and seat assigned to that passenger (:class:`int`) For example: .. literalinclude:: Change_Dest_psgD.test :language: pycon :start-after: --in-ini :end-before: --in-fi You are required to implement the following functions and deliver **all of them** in the same module :mod:`bus3` (file :file:`bus3.py`). The tentative weight for each problem is 25%, 50% and 25% respectively. .. warning:: Do not leave pieces of code that are wither incomplete or contain syntax errors in the file to deliver since that would result in a 0.0 grade for all the functions. ------------------------------------------------------------------------------------------------ The first function is: .. py:function:: Change_Dest_psgD(psgD, old, new) such that **given** - *psgD* a :class:`dict` as described above - *old*, *new*, two :class:`str` with distinations **updates** *psgD* by changing all the values for passengers with the *old* destination to the *new* destination. For example, the expected output for the passenger dict above would be: .. literalinclude:: Change_Dest_psgD.test :language: pycon :start-after: --out-ini :end-before: --out-fi Doctests are available in the :download:`Change_Dest_psgD.test` file. ------------------------------------------------------------------------------------------------ The second function is intended to construct a new dictionary for the bus driver that lists the passengers that are suposed to get off the bus at each stop. To that purpose, you are asked to deliver the following function: .. py:function:: Construct_stopsD(psgD) such that **given** *psgD* a passenger's :class:`dict` as described above **returns** a new :class:`dict` where: #. The keys are the stops (:class:`str`) where at least one passenger is supposed to get out of the bus. #. The value associated to each key is a :class:`list` with the passengers with the passengers that are supposed to get out of the bus at that stop. Each passenger is represented by a 4-place :class:`tuple` with: - the passenger last name (:class:`str`) - the passenger id number (:class:`str`) - the row and seat numbers (:class:`int`) The input :class:`dict` should **not** be modified. For example: .. literalinclude:: Construct_stopsD.test :language: pycon :start-after: --in-ini :end-before: --out-fi Doctests are available in the :download:`Construct_stopsD.test` file. ------------------------------------------------------------------------------------------------ The third function is intended to order all the lists in the values of the :class:`dict` produced by the previous function: .. py:function:: Sort_stopsD(stopsD) such that **given** *stopsD* a :class:`dict` as described for the output of the previous function **updates** *stopsD* by **ordering** the passengers in the lists for each stop according to the following criteria (in this order of priority): #. The *row*, in ascending order. #. The last name, in alphabetic order. #. The *id number* in ascending order. For example: .. literalinclude:: Sort_stopsD.test :language: pycon :start-after: --ini :end-before: --fi Doctests are available in the :download:`Sort_stopsD.test` file.