Provided code:
lab4.py
Problem description:
lab4.pdf