The moment a one-off script becomes a reusable tool. Ten labs on Module 7 — rebuilding Tier 4's account-finder as a proper fetch → analyze → report function chain, over the same real fixture.
Write fetch_users() that takes no parameters and returns USERS. Call it, print type() of the result, then its len().
<class 'list'> then 12Write is_suspended(user) that returns True if user["status"] == "SUSPENDED". Call it on USERS[2] (Bina), then USERS[0] (Julio).
True then FalseWrite has_zero_groups(user) that returns True if len(user["groups"]) == 0. Call it on USERS[3] (Dana), then USERS[0] (Julio).
True then FalseWrite is_flagged(user) that returns is_suspended(user) or has_zero_groups(user) — a function calling functions. Call it on USERS[2] (Bina), USERS[3] (Dana), USERS[0] (Julio).
True, True, FalseWrite filter_flagged(users) that loops users and returns a list of every one where is_flagged(u) is True. Call it on fetch_users()'s result. Print len(), then a list of just their first names.
5 then ['Bina', 'Dana', 'Tri', 'Rosa', 'Pat']Write get_department_safe(user) that returns user["profile"].get("department", "Unknown"). Call it on USERS[7] (Layla), then USERS[0] (Julio).
Unknown then ITWrite build_report_line(user) that RETURNS (doesn't print) the string "FIRST LAST -- STATUS -- DEPARTMENT", using get_department_safe() internally. Call it on USERS[2] (Bina) and print the result yourself.
Bina Patel -- SUSPENDED -- SalesWrite print_report(flagged_users) that loops and prints build_report_line(u) for each — a side-effect-only function, no return. Call it on filter_flagged(fetch_users()), then print what print_report itself returned.
None — confirms it's a pure side-effect functionWrite a function that creates a local variable and returns it. Call it and print the result. Then try to print that same variable name OUTSIDE the function — confirm it crashes.
NameErrorWrite main() that calls fetch_users() → filter_flagged() → prints "Flagged accounts: N" → print_report(), reusing every function from Labs 1-9. Call main().
Flagged accounts: 5Bina Patel -- SUSPENDED -- SalesDana Morris -- ACTIVE -- ITTri Nguyen -- DEPROVISIONED -- SalesRosa Gomez -- SUSPENDED -- ITPat Hogan -- DEPROVISIONED -- Sales
Open problems/tier05_modular_audit.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.