Aera Technology Interview Question

Python code