← Course Home
Module 13 · Tier 2

Employee Lookup Tool

A helpdesk tech's "who is this person" quick-reference script. Ten labs, nothing but Modules 2-3 — lists, dicts, indexing, safe access. No loops yet, so every lookup here is direct.

Lab 1

The Basic Lookup Line

Create employee = {"name": "Diego Alvarez", "department": "IT", "email": "dalvarez@example.com"}. Print one formatted line: "NAME -- DEPARTMENT (EMAIL)".

Diego Alvarez -- IT (dalvarez@example.com)
Lab 2

A Directory, By Index

Create a list of 3 employee dicts (name + department each) for Diego Alvarez (IT), Priya Nair (Security), and Owen Clarke (Sales). Access the first one by [0] and print "NAME -- DEPARTMENT".

Diego Alvarez -- IT
Lab 3

Does This Department Exist?

Create departments = ["IT", "Security", "Sales"]. Print whether "Security" is in the list, then whether "Marketing" is — two lines, using in.

True then False
Lab 4

The Missing Phone Number

Create employee = {"name": "Priya Nair", "department": "Security"} — no phone field. Print employee.get("phone", "No phone on file").

No phone on file
Lab 5

Updating a Record

Create employee = {"name": "Owen Clarke", "department": "IT"}. Print employee["department"]. Then reassign employee["department"] = "Security" (a department transfer) and print it again.

IT then Security
Lab 6

Who's Their Manager?

Create employee = {"name": "Diego Alvarez", "manager": {"name": "Lin Park", "email": "lpark@example.com"}}. Print just the manager's name — employee["manager"]["name"].

Lin Park
Lab 7

Deep Chain, By Index

Create a list of 3 employee dicts, each with a nested "manager" dict (name + email). Print the THIRD employee's manager's email in one chained expression: employees[2]["manager"]["email"].

lpark@example.com (or whatever email you gave that manager)
Lab 8

Clearing the Temp Password

Create employee = {"name": "Priya Nair", "temp_password": "Xy9!work2"} (issued at account creation). Print the dict. Then .pop("temp_password") it (simulating first login) and print the dict again.

{'name': 'Priya Nair', 'temp_password': 'Xy9!work2'} then {'name': 'Priya Nair'}
Lab 9

Merging Two Records

Create base_info = {"name": "Owen Clarke", "department": "Sales"} and contact_info = {"email": "oclarke@example.com", "phone": "555-0134"} — two separate systems' data on the same person. Merge them with {**base_info, **contact_info} and print the result.

{'name': 'Owen Clarke', 'department': 'Sales', 'email': 'oclarke@example.com', 'phone': '555-0134'}
Lab 10 · Capstone

The Full Lookup Result

Build a small directory: a list of 5 employee dicts, where some have a "manager" key and some have a "phone" key, and most don't have either. Pick one specific employee by index. Print a 4-line "Employee Lookup Result" card: name, department, phone (guarded with .get(), default "Not on file"), and manager name (guarded, default "No manager on file") — reusing every mechanic from Labs 1-9.

→ four lines, e.g.:
Employee Lookup Result: Owen Clarke
Department: Sales
Phone: 555-0134
Manager: No manager on file
Now go practice

Open problems/tier02_employee_lookup.py and do all 10 problems locally. Run python check.py in problems/ to grade everything.

Tier 2 complete

On to Tier 3

single-record lookup → list indexing → membership checks → .get() with default → updating a field → nested dict access → deep chained access → .pop() → merging two dicts → the full guarded lookup card.

← Back to Module 13