Blog

A blog of Python-related topics and code.

Which is the cleanest coffee shop chain?

The UK government Food Standards Agency (FSA) collects together data on food hygiene from inspections carried out by local authorities in England, Wales and Northern Ireland participating in the national Food Hygiene Rating Scheme (FHRS).

How do Telegraph readers die?

The Daily Telegraph publishes an announcements page online. The death announcements category consists of a series of short paragraphs placed by readers communicating the recent death of a relative. The fact that these relatives often expire either "peacefully" or "suddenly" (and sometimes both) is the basis of the peacefully/suddenly game: a popular pastime for long train journeys in the United Kingdom.

The "Mystery Curve"

A family of curves in the complex plane may be generated by the formula:

Visualizing modular multiplication tables

Here is a short Python program to visualize the table of multiplication modulo $n$. The integers $i$ and $j = 1,2,3,\cdots,N-1$ number the rows and columns of the image plot produced. $n$ and $N$ are supplied as command line arguments (if $N$ is not supplied, it defaults to $n$).

Adding ticks to a Matplotlib line

LineTicks is a simple class that I put together to add tick marks and labels to a plotted line (not the axes, which Matplotlib already handles well with lots of methods for customization). The code is available on github.