← Course Home
Module 13 · Tier 8

Monthly Report Generator

How admins turn an admin-console export into something a manager can read. Ten labs on Module 10 — writing an export, reading it back, and generating a formatted report file.

Lab 1

Write Today's Export

Write the real USERS fixture out to "p1_export.json" using json.dump() — simulating pulling today's export from an admin console.

file created, no crash
Lab 2

Read It Back

Read "p1_export.json" back with json.load(). Print len() of the result, then whether it equals the original USERS.

12 then True
Lab 3

Build the Summary

Write build_department_summary(users) that returns a dict of {department: count}, guarding the missing-department record. Call it on USERS.

{'IT': 3, 'Security': 2, 'Sales': 3, 'Engineering': 3, 'Unknown': 1}
Lab 4

Write the Report

Write the summary from Lab 3 to "p4_report.txt", one "DEPT: COUNT" line per department.

file written, no crash
Lab 5

Read the Report Back

Read "p4_report.txt" back and print its contents.

IT: 3
Security: 2
Sales: 3
Engineering: 3
Unknown: 1
Lab 6

Append a Timestamp

Write the department summary to "p6_report.txt" with "w" mode (fresh each time), then open it AGAIN with "a" mode and append "Generated on: 2026-07-26\n". Read the file back and print it.

→ the 5 department lines, then Generated on: 2026-07-26
Lab 7

Guard a Missing Export

Write load_export_safe(path) that reads and returns JSON from a file, returning [] if the file doesn't exist. Call it on "p1_export.json" (print len()), then on "p7_does_not_exist.json" (print the result).

12 then []
Lab 8

Reuse the Summary Function

Call your build_department_summary() from Lab 3 again, this time on data you loaded from a file with load_export_safe() instead of the in-memory fixture. Confirm it produces the same result.

→ same dict as Lab 3
Lab 9

The Export-to-Summary Chain

Write USERS to "p9_export.json", read it back, and build the department summary from the re-loaded data — three steps in one script.

{'IT': 3, 'Security': 2, 'Sales': 3, 'Engineering': 3, 'Unknown': 1}
Lab 10 · Capstone

The Full Monthly Report

Chain everything: write USERS to "p10_export.json" → read it back → build the department summary → write a report to "p10_report.txt" starting with a "Monthly Department Report" header line, then the department lines → read the report file back and print it to confirm.


Monthly Department Report
IT: 3
Security: 2
Sales: 3
Engineering: 3
Unknown: 1
Now go practice

Open problems/tier08_monthly_report.py and do all 10 problems locally. Uses fixture.py -- type it in first from DAY1_01_FIXTURE.md if it's not already in this folder. Run python check.py in problems/ to grade everything.

Tier 8 complete

On to Tier 9

writing today's export → reading it back → building the summary → writing the report → reading it back → appending a timestamp → guarding a missing export → reusing the summary function → the export-to-summary chain → the full monthly report.

← Back to Module 13