Pregunta de entrevista de Apple

Oop question in python and make the function.