added Python code for chapter 11