Python version of the example code for #IDEALMOOC