Cognizant interview question

Sql codes and python code