The final version of the Python program.