← Course Home
Module 13 · Tier 3

Department Roster Report

The roster HR asks IT for every quarter. Ten labs on Modules 4-5 — mutability, aliasing, real copies, and the actual 12-person course fixture. Still no loops (that's Tier 4) — every record here is reached by direct indexing.

Lab 1

Index Into the Real Fixture

Using the real USERS fixture, print "FIRSTNAME -- DEPARTMENT" for USERS[0], guarding the department with .get(..., "Unknown").

Julio -- IT
Lab 2

A Real, Independent Copy

Take original = USERS[4] (Kelly). Print original["status"]. Make copy = dict(original), set copy["status"] = "SUSPENDED" (flagging a duplicate record without touching the source). Print original["status"] again, then copy["status"].

ACTIVE, ACTIVE, SUSPENDED — the original is untouched, top-level fields really do copy independently
Lab 3

The Aliasing Gotcha

alias = USERS[0] — NOT a copy, just a second name for the same dict. Set alias["profile"]["department"] = "Temp". Print USERS[0]["profile"]["department"] — did the "real" record change too? Then set it back to "IT" and print again to confirm the reset.

Temp then ITalias and USERS[0] are the exact same object; there was never a copy
Lab 4

is vs ==

Print USERS[0] is USERS[0], then dict(USERS[0]) is USERS[0], then dict(USERS[0]) == USERS[0] — three lines.

True, False, True — a fresh copy is never the SAME object, even when its contents are equal
Lab 5

Manually Building an IT Roster

Julio (USERS[0]) and Dana (USERS[3]) are both in IT. Build it_roster = [USERS[0], USERS[3]] and print each one's firstName — two lines, no loop, just direct indexing into your new list.

Julio then Dana
Lab 6

The Missing-Department Record

Print USERS[7]'s department, guarded with .get(..., "Unknown") — you already know this record (Layla) is missing the key entirely.

Unknown
Lab 7

The Shallow-Copy Gotcha

original = USERS[0]. shallow = dict(original) — looks like a copy. Append a new group to shallow["groups"]. Print len(original["groups"]) then len(shallow["groups"]).

3 then 3 — BOTH changed. dict() only copies the top level; nested lists/dicts (like groups) are still the exact same shared object in both.
Lab 8

Comparing Two Records

Print whether USERS[0] and USERS[3] have the same department, then whether USERS[0] and USERS[1] do — two lines.

True then False
Lab 9

Join By Key

Get USERS[0]'s email, then look up their login count in LOGIN_COUNTS using that email as the key (guard with .get(), default "No login data").

142
Lab 10 · Capstone

One Manual Roster Line

For USERS[7] (Layla): print a 3-line report entry combining safe department access (Lab 6), a full name, and a login-count join by email (Lab 9) — "Roster entry: FIRST LAST", "Department: ...", "Login count: ...".


Roster entry: Layla Haddad
Department: Unknown
Login count: 12
Now go practice

Open problems/tier03_department_roster.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 3 complete

On to Tier 4

indexing the real fixture → real copies vs aliasing → the aliasing gotcha → is vs == → manually building a roster → the missing-department guard → the shallow-copy gotcha → comparing records → joining by key → the full manual roster line.

← Back to Module 13