completed ex3.py