completed ex31.py