Even without running as a CLI, structuring script logic into small pure functions (rather than top-level code) makes it testable and reusable — this matters because the grader in this course calls your functions directly.
python
def parse_amount(raw: str) -> float:
cleaned = raw.strip().replace(",", "")
return float(cleaned)
def format_report(rows: list[dict]) -> str:
lines = [f"{r['name']}: {r['value']}" for r in rows]
return "\n".join(lines)Separating "pure logic" functions from I/O (printing, file reads, network calls) means the logic can be tested without mocking the outside world — a core software engineering practice used constantly in real Python codebases, including blockchain tooling scripts.