Code written for edx python course.