added Python code for chapter 17