Data Axle Interview Question

converting java code to python