| 1 | import json |
| 2 | |
| 3 | |
| 4 | def write_report(path, numbers): |
| 5 | total = sum(numbers) |
| 6 | count = len(numbers) |
| 7 | stats = { |
| 8 | "count": count, |
| 9 | "total": total, |
| 10 | "mean": total / count if count else 0, |
| 11 | "max": max(numbers) if numbers else None, |
| 12 | } |
| 13 | with open(path, "w") as f: |
| 14 | json.dump(stats, f, sort_keys=True) |
| 15 |