code for Shannon's py class.