Exercises from Chapter 5 of Think Python