Domanda di colloquio di Kepler Group

How would the python language for this look like?