MAQ Software Interview Question

Interviewer asked me to write a code in python which was of medium difficulty level.