Digital Clock, In Class App =========================== Contents -------- .. toctree:: :maxdepth: 1 Indices and tables ------------------ * :ref:`genindex` * :ref:`modindex` * :ref:`search` Exercise Overview ----------------- For this week, the goal is to create an app that will display the current time in the terminal using a digital clock face. The app should have the following functionality: * Clear the terminal * Fetch the current time from the system * Parse the hr:min:sec:am|pm fields out * Print the hr:min:sec:am|pm fields to the screen to resemble a digital clock * A good reference for unicode blocks is `here `_, though note that not all of them will make good pixel replica. * Sleep for 1 second and repeat... This will require the :py:class:`~datetime.datetime` class from :py:mod:`datetime` package and the :py:func:`~time.sleep` method from the :py:mod:`time` package. You should setup a project in PyCharm in order to make debugging your app as simple as possible. Stub Code --------- To allow you to focus on the main kernel of the program, some stub code has been created with the following functions in it: * :py:func:`gen_font_table` - Generates a font table containing 8x8 characters. The font table is a dictionary, keyed by character / digit, with each character a 2-dimensional list of pixels. A pixel value of 0 represents off and a pixel value of 1 represents on. For example: .. code-block:: python tbl = {} tbl["0"] = ((0, 0, 0, 1, 1, 0, 0, 0), (0, 0, 1, 0, 0, 1, 0, 0), (0, 1, 0, 0, 0, 0, 1, 0), (0, 1, 0, 0, 0, 0, 1, 0), (0, 1, 0, 0, 0, 0, 1, 0), (0, 1, 0, 0, 0, 0, 1, 0), (0, 0, 1, 0, 0, 1, 0, 0), (0, 0, 0, 1, 1, 0, 0, 0),) * :py:func:`clear_screen` - Handles sending the ASCII escape character to the terminal that clears the screen. .. note:: The terminal in PyCharm does not handle all ASCII terminal codes and so the :py:func:`clear_screen` method may not work in PyCharm for you. Instead, the text will just scroll vertically. If you run your app in a standalone Python interpreter, the :py:func:`clear_screen` method should work correctly. You can find the stub code :download:`here `. Datetime -------- A description of using the datetime module can be found :ref:`here ` Solution -------- When you are ready to see one possible solution, try :download:`this file ` .. _UnicodeBlocks: https://en.wikipedia.org/wiki/Box-drawing_character