EY interview question

Python related and SQL queries: