Pergunta de entrevista da empresa UBS

Blocks of code in python and the expected outcome