Do problem 7 in Python.