Python for Designers

by Roberto Arista

Fork me on GitHub

Workbook

workbook.svg

exercise 14.1

Write a script able to create a table on multiple A4 pages describing an arbitrary sequence of Unicode characters. Each line of the table should report binary, decimal, and UTF-8 hexadecimal representations. Also, the line should render the character itself surrounded by two pipes “|” in gray and a description of the character according to the Unicode standard (check the unicodedata module). Here you can check a PDF example. Table header (in bold) and page numbering would be a nice to have, don’t you think?

>>> Solution (.py)

unicodeTable.png

exercise 14.2

Draw a multiplication table. You should be able to define the first and last values of the range of multiplied numbers (from 1 to 10, from 10 to 100, and so on). Then, extend the program capabilities in order to compute many different operations like addition, difference, power of, and division. Check the operator module for some hints. With different operations, you will probably face very large numbers or numbers with a decimal part. In the first case, scale down the type size if the number does not fit the cell size, in the other case use some tools from the fractions module mixed with OpenType features to typeset numbers like 0.333333333 in a compact way. Here is a an example.

>>> Solution (.py)

operationMatrix.png

exercise 14.3

The following exercise consists of typesetting a color table. This CSV file contains a collection of hex values followed by a name; it is compiled from this Wikipedia colors list. Your table should show a color swatch, the name, the HLS value, the RGB value, and the hexadecimal value. You are free to choose the page format, but the data should spread automatically over as many pages needed. Each page should have a header describing the content of the columns. Here you can find a PDF example.

>>> Solution (.py)

colors.png