Write a Python script with explanations
Get working Python code plus an explanation of how it works.
Write a Python script that [describe the task]. Input: [describe input data/format] Output: [describe expected output] Python version: [e.g. 3.12] Libraries allowed: [e.g. standard library only, pandas] Requirements: clear variable names, comments for non-obvious parts, error handling for [likely problems], and a small example of how to run it. After the code, explain how it works in plain English and list any assumptions you made.
How to use it
Run the code on test data first. Read the assumptions list and correct any that are wrong.