Rewriting the code for "Exploring Everyday Things with R and Ruby" in Python