Ex. 4.1 from the live coding session.ipynb