The Standard Library Exists · capstone
Capstone project: Capstone: Build the Activity Briefing
The project has four working parts:
days_betweenturns ISO text into dates and measures their distance;count_categoriesrepresents category frequencies as a Counter;summarize_minutesreturns the mean and median, orNonefor no records.format_category_countsturns the Counter into one alphabetical line.
The capstone gives those parts one public result: build_briefing(records). This is where library choices become a useful program rather than three API demos.
Compose the proven contracts
Do not assume the first record has the earliest date or the last record has the latest. Start both boundaries from the first record, visit every record, and update them through comparisons. This project requires fixed-width YYYY-MM-DD date
Then call days_between(earliest, latest), format_category_counts(records), and summarize_minutes(records). The capstone coordinates their results; it does not repeat parsing, counting, sorting, or statistics.
Keep data and display responsibilities visible
For non-empty records, return exactly four lines:
Activity briefing
Dates: <earliest> to <latest> (<distance> days apart)
Categories: <alphabetical name=count pairs>
Minutes: mean=<mean>; median=<median>
For an empty No activities recorded.. There is no date
main() prints the briefing for the prepared ACTIVITIES. The if __name__ == "__main__" guard means running the file displays the report, while importing it for grading or reuse stays quiet.
Put the job-to-API route in the order used by this project:
Drag the options into order, or use the arrow buttons.
Find a likely standard-library module.
Try a tiny example.
State the job in ordinary words.
Read the selected object's input, return, and failure contract.
Compose the proven operation into the project.
Which ownership map matches the finished project?
Finish the file, run it, and submit.
Before you do, shuffle ACTIVITIES into a different order and run it once more. The briefing should come out identical. Every part of this chapter was built so that it would.
Task
Finish activity_report.py.
Implement build_briefing(records) with this contract:
return
No activities recorded.for an empty; find the earliest and latest ISO date without assuming input order;
call
days_between,format_category_counts, andsummarize_minutesrather than repeating their jobs;return the exact four-line layout shown in the lesson.
Then implement main() so it prints build_briefing(ACTIVITIES). Keep the prepared if __name__ == "__main__" guard. Running the file should display the sample briefing; importing it should only expose its reusable