Exercises 18, 19, 20 from learning python the hardway