IBM interview question

python coding