Do problem 32 in Python.