Expressions =========== Save all functions into the same file named ``expressions.py``. #. Write function :py:func:`items_count_1` that takes a string (:class:`str`) which represents a Python expression and returns two integers (:class:`int`) corresponding respectively to the number of alphabetical characters and digits. Examples: .. literalinclude:: items_1.txt :language: python3 :lines: 3- .. note:: More tests are provided in the :download:`items_1.txt` file. #. Write function :py:func:`items_count_2` that takes a string which represents a Python expression and returns two integers corresponding to the number of items of the following types found in this expression. The first type are the following characters corresponding to some operators, ``'+'``, ``'-'``, ``'*'``, ``'/'``, ``'%'``, ``'='``, ``'!'``, ``'>'`` and ``'<'``. The second type are the following bracket type characters: ``'('``, ``')'``, ``'['``, ``']'``, ``'{'`` and ``'}'``. Examples: .. literalinclude:: items_2.txt :language: python3 :lines: 3- .. note:: More tests are provided in the :download:`items_2.txt` file. #. Write the function :py:func:`well_parenthesized_1` that takes a string (:class:`str`) which represents a Python expression and returns ``True`` if it is well-parenthesized or ``False`` otherwise. A well-parenthesized expression must fulfil the following rules: 1. while traversing it left to right, the number of open parenthesis must be always greater than or equal to the number of closed parenthesis. 2. at the end of the traversal, the number of open parenthesis must be equal to the number of closed parenthesis. See the following examples: .. literalinclude:: parenthesis_1.txt :language: python3 :lines: 3- .. note:: More tests are provided in the :download:`parenthesis_1.txt` file. #. Write the function :py:func:`well_parenthesized_2` that takes a string (:class:`str`) which represents a Python expression and returns the string ``'correct'`` if it is a well-parenthesized expression. If not, the function returns the string ``'incorrect closed parenthesis'`` together with the first position (string index) (:class:`int`) in which rule 1 fails. If rule 2 fails, the function returns the string ``'more open than closed parenthesis'``. Examples: .. literalinclude:: parenthesis_2.txt :language: python3 :lines: 3- .. note:: More tests are provided in the :download:`parenthesis_2.txt` file. .. rubric:: Solution A solution of these functions is provided in the :download:`expressions.py` file.