Phone calls =========== There are one or more files that contain a sequence of numbers corresponding to the telephone calls of some office. Each line of the file contains a single telephone number, corresponding to a call. As an example, you can download the file :download:`calls.txt` that has the following content: .. literalinclude:: examples/calls.txt :language: python Save all functions into the same file named ``phone.py``. #. Write a function :py:func:`ncalls1` that takes the name of a file (string) with the given content, and returns how many times the number 012 has received a call and how many the number 11811. Examples: .. literalinclude:: ncalls1.txt :language: python3 :lines: 8- .. note:: More tests are provided in file :download:`ncalls1.txt` #. Write a function :py:func:`ncalls2` that takes the name of a file (string) with the given content and the name of an output file, and computes how many times the number 012 has received a call and how many the number 11811. The function has to create a new file with the name given as second parameter and with two lines. Each line will contain the telephone number (012 or 11811) and the number of times it has received a call, separated by one whitespace. Examples: .. literalinclude:: ncalls2.txt :language: python3 :lines: 8-12 .. note:: More tests are provided in file :download:`ncalls2.txt` #. Write a function :py:func:`consecutive_numbers` that takes the name of a file (string) with the decribed content, and returns True if there are two equal consecutive numbers in the file and False otherwise. Examples: .. literalinclude:: consecutive_numbers.txt :language: python3 :lines: 8-9 .. note:: More tests are provided in file :download:`consecutive_numbers.txt` #. Write a function :py:func:`prefix` that takes the name of a file (string) with the described content, the name of an output file (string) and another string corresponding to a prefix. The function has to write in the second file those telephone numbers in the first file with the given prefix. Examples: .. literalinclude:: prefix.txt :language: python3 :lines: 8- .. note:: More tests are provided in file :download:`prefix.txt` .. rubric:: Solution A solution of these functions is provided in the :download:`phone.py` file.