In Time Tec Interview Question

Logical approach for python and sql