Magnaquest interview question

SQL queries, basic Python code