Completed ex5.py