0%

The Standard Library Exists · capstone

Capstone project: Capstone: Build the Activity Briefing

The project has four working parts:

  • days_between turns ISO text into dates and measures their distance;

  • count_categories represents category frequencies as a Counter;

  • summarize_minutes returns the mean and median, or None for no records.

  • format_category_counts turns 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 , so their text order matches their calendar order.

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 , return exactly No activities recorded.. There is no date , category list, mean, or median to invent.

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, and summarize_minutes rather 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 .