[description of the task is in the picture!][1]
I am struggling to write any form of code as to answer the question outlined in the picture, it must be on python and