Week 14 Assignment
Variant 1: The Event Planner
You are managing a gala event. You have a “Master Guest List” of people who were invited and a “Check-in List” of emails of people who actually arrived. You need to generate a report on attendance.
Write a program with the following three functions:
create_guest_lookup(guest_list):- Accepts a list of dictionaries where each dict is
{'name': str, 'email': str}. - Returns a Dictionary where keys are emails and values are names.
- Accepts a list of dictionaries where each dict is
categorize_guests(guest_lookup, check_in_emails):- Accepts the lookup dictionary and a list of email strings (check-ins).
- Returns two Sets:
no_shows: Emails in the guest list but NOT in the check-in list.crashers: Emails in the check-in list but NOT in the guest list.
generate_badges(guest_lookup, check_in_emails):- Accepts the lookup dictionary and the check-in list.
- Uses a List Comprehension to create a list of badge strings for verified guests only (those who were invited AND checked in).
- Format:
"Welcome, [Name]!"(Names must be in UPPERCASE). - Return the list sorted alphabetically.
Testing Inputs
guests = [
{'name': "Alice Smith", 'email': "alice@example.com"},
{'name': "Bob Jones", 'email': "bob@example.com"},
{'name': "Charlie Brown", 'email': "char@example.com"}
]
check_ins = ["bob@example.com", "char@example.com", "dave@example.com"]
Expected Output
No Shows: {'alice@example.com'}
Crashers: {'dave@example.com'}
Badges: ['Welcome, BOB JONES!', 'Welcome, CHARLIE BROWN!']
Variant 2: The Library Auditor
You are auditing a library system. You have a list of books that were borrowed and a list of ISBN numbers for books that were returned to the drop box today. You need to identify which books are still missing.
Write a program with the following three functions:
create_book_catalog(borrowed_books):- Accepts a list of tuples:
(ISBN, Title, Borrower_Name). - Returns a Dictionary where keys are ISBNs (int) and values are Titles (str).
- Accepts a list of tuples:
audit_returns(catalog, returned_isbns):- Accepts the catalog dictionary and a list of returned ISBNs (integers).
- Returns two Sets:
overdue_books: ISBNs that are in the catalog but NOT in the returned list.unknown_returns: ISBNs in the returned list that represent books not currently marked as borrowed (not in catalog).
format_overdue_report(catalog, overdue_isbns):- Accepts the catalog dictionary and the set of overdue ISBNs.
- Uses a List Comprehension (or dictionary comprehension) to create a list of strings.
- Format:
"MISSING: [Title] (ISBN: [Number])" - Return the list sorted alphabetically by Title.
Testing Inputs
borrowed = [
(1001, "The Great Gatsby", "John"),
(1002, "1984", "Sarah"),
(1003, "Python 101", "Mike")
]
returned = [1003, 1001, 9999]
Expected Output
Overdue ISBNs: {1002}
Unknown Returns: {9999}
Report: ['MISSING: 1984 (ISBN: 1002)']
Variant 3: The Inventory Manager
You work at a warehouse. You have a “Manifest” (what was supposed to be shipped) and a “Scanned List” (barcodes of items actually loaded onto the truck). You need to find discrepancies.
Write a program with the following three functions:
map_products(manifest):- Accepts a list of dictionaries:
{'barcode': str, 'product_name': str, 'price': float}. - Returns a Dictionary where keys are barcodes and values are product names.
- Accepts a list of dictionaries:
compare_shipment(product_map, scanned_barcodes):- Accepts the product map and a list of scanned barcode strings.
- Returns two Sets:
missing_items: Barcodes in the map but NOT scanned.extra_items: Barcodes scanned but NOT in the map (unexpected items).
calculate_missing_value(manifest, missing_set):- Accepts the original manifest list and the set of missing barcodes.
- Uses a List Comprehension (or
sumwith a generator) to calculate the total price of the missing items. - Returns the total float value formatted or rounded to 2 decimal places.
Testing Inputs
manifest = [
{'barcode': "A123", 'product_name': "Laptop", 'price': 1000.00},
{'barcode': "B456", 'product_name': "Mouse", 'price': 25.50},
{'barcode': "C789", 'product_name': "Monitor", 'price': 200.00}
]
scanned = ["A123", "B456", "D000"]
Expected Output
Missing Barcodes: {'C789'}
Extra Barcodes: {'D000'}
Total Value Lost: 200.0
Variant 4: Course Attendance Tracker
You are a teaching assistant. You have an “Enrollment List” of students registered for the final exam and a “Sign-in Sheet” of student IDs collected at the exam hall. You need to identify who skipped the exam.
Write a program with the following three functions:
build_class_roster(enrollment_data):- Accepts a list of dictionaries:
{'student_id': int, 'full_name': str}. - Returns a Dictionary where keys are
student_idand values arefull_name.
- Accepts a list of dictionaries:
verify_attendance(roster_dict, sign_in_ids):- Accepts the roster dictionary and a list of integers (signed-in IDs).
- Returns two Sets:
absent_students: IDs in the roster but NOT in the sign-in list.unregistered_students: IDs in the sign-in list but NOT in the roster.
generate_absence_report(roster_dict, absent_ids):- Accepts the roster dictionary and the set of absent IDs.
- Uses a List Comprehension to create a list of strings.
- Format:
"ABSENT: [Name] (ID: [ID])" - Return the list sorted alphabetically by name.
Testing Inputs
enrollment = [
{'student_id': 501, 'full_name': "Sam Porter"},
{'student_id': 502, 'full_name': "Fragile Express"},
{'student_id': 503, 'full_name': "Die Hardman"}
]
signed_in = [501, 503, 999]
Expected Output
Absent IDs: {502}
Unregistered IDs: {999}
Report: ['ABSENT: Fragile Express (ID: 502)']
Variant 5: E-Commerce Order Validator
You manage an online store. You have an “Order Log” of all purchases made yesterday and a “Shipping Manifest” of tracking numbers that were actually scanned onto trucks. You need to find which orders haven’t shipped yet.
Write a program with the following three functions:
map_orders(order_log):- Accepts a list of dictionaries:
{'tracking_num': str, 'customer_city': str}. - Returns a Dictionary where keys are
tracking_numand values arecustomer_city.
- Accepts a list of dictionaries:
check_shipments(order_map, scanned_tracking_nums):- Accepts the order map dictionary and a list of strings (scanned tracking numbers).
- Returns two Sets:
delayed_orders: Tracking numbers in the order map but NOT scanned.phantom_shipments: Tracking numbers scanned but NOT in the order map.
format_delay_notices(order_map, delayed_set):- Accepts the order map and the set of delayed tracking numbers.
- Uses a List Comprehension to create a list of strings.
- Format:
"DELAYED: Package [Tracking#] to [City]" - Return the list sorted alphabetically by City name.
Testing Inputs
orders = [
{'tracking_num': "TN100", 'customer_city': "New York"},
{'tracking_num': "TN101", 'customer_city': "London"},
{'tracking_num': "TN102", 'customer_city': "Tokyo"}
]
scanned = ["TN100", "TN102", "TN999"]
Expected Output
Delayed Orders: {'TN101'}
Phantom Shipments: {'TN999'}
Report: ['DELAYED: Package TN101 to London']
Variant 6: Clinic Appointment Auditor
You work at a medical clinic. You have a “Schedule” of patients expected today and a “Check-in Log” of social security numbers (SSNs) for patients who actually arrived at the front desk. You need to flag the no-shows.
Write a program with the following three functions:
create_patient_index(daily_schedule):- Accepts a list of dictionaries:
{'ssn': int, 'patient_name': str}. - Returns a Dictionary where keys are
ssnand values arepatient_name.
- Accepts a list of dictionaries:
audit_check_ins(patient_index, arrived_ssns):- Accepts the patient index dictionary and a list of integers (arrived SSNs).
- Returns two Sets:
missed_appointments: SSNs in the schedule but NOT in the check-in log.walk_in_patients: SSNs in the check-in log but NOT in the schedule.
list_no_shows(patient_index, missed_set):- Accepts the patient index and the set of missed SSNs.
- Uses a List Comprehension to create a list of strings.
- Format:
"NO-SHOW: [Name]"(Names must be converted to UPPERCASE). - Return the list sorted alphabetically.
Testing Inputs
schedule = [
{'ssn': 11122, 'patient_name': "John Doe"},
{'ssn': 33344, 'patient_name': "Jane Smith"},
{'ssn': 55566, 'patient_name': "Emily Blunt"}
]
arrived = [11122, 55566, 77788]
Expected Output
Missed Appointments: {33344}
Walk-ins: {77788}
Report: ['NO-SHOW: JANE SMITH']
Variant 7: Airport Luggage Tracker
You work at an airport baggage claim. You have a “Flight Manifest” of bags that were loaded onto the plane and a “Scanner Log” of bags that were successfully unloaded onto the carousel. You need to identify lost luggage.
Write a program with the following three functions:
build_baggage_map(flight_manifest):- Accepts a list of dictionaries:
{'tag_id': str, 'passenger_name': str}. - Returns a Dictionary where keys are
tag_idand values arepassenger_name.
- Accepts a list of dictionaries:
reconcile_bags(bag_map, scanned_tags):- Accepts the baggage map and a list of strings (scanned tag IDs).
- Returns two Sets:
lost_bags: Tags in the manifest but NOT scanned.mystery_bags: Tags scanned but NOT in the manifest.
generate_lost_report(bag_map, lost_tag_set):- Accepts the baggage map and the set of lost tags.
- Uses a List Comprehension to create a list of strings.
- Format:
"MISSING: Bag [Tag] (Owner: [Name])" - Return the list sorted alphabetically by the Passenger’s Name.
Testing Inputs
manifest = [
{'tag_id': "BAG-001", 'passenger_name': "Wei Chen"},
{'tag_id': "BAG-002", 'passenger_name': "Anita Roy"},
{'tag_id': "BAG-003", 'passenger_name': "Leo Das"}
]
scanned = ["BAG-001", "BAG-003", "BAG-999"]
Expected Output
Lost Bags: {'BAG-002'}
Mystery Bags: {'BAG-999'}
Report: ['MISSING: Bag BAG-002 (Owner: Anita Roy)']
Variant 8: Payroll Timesheet Auditor
You are an HR administrator. You have a “Staff Directory” of active employees and a “Timesheet Log” of employee IDs who submitted their work hours this week. You need to find who forgot to submit their timesheet.
Write a program with the following three functions:
create_staff_dict(staff_list):- Accepts a list of dictionaries:
{'emp_id': int, 'department': str}. - Returns a Dictionary where keys are
emp_idand values aredepartment.
- Accepts a list of dictionaries:
audit_submissions(staff_dict, submitted_ids):- Accepts the staff dictionary and a list of integers (IDs who submitted).
- Returns two Sets:
missing_timesheets: IDs in the directory but NOT in the submission list.invalid_ids: IDs in the submission list but NOT in the directory (former employees?).
format_reminders(staff_dict, missing_set):- Accepts the staff dictionary and the set of missing IDs.
- Uses a List Comprehension to create a list of strings.
- Format:
"REMINDER: Staff #[ID] ([Department])" - Return the list sorted numerically by Employee ID.
Testing Inputs
staff = [
{'emp_id': 101, 'department': "Sales"},
{'emp_id': 102, 'department': "IT"},
{'emp_id': 103, 'department': "HR"}
]
submitted = [101, 103, 500]
Expected Output
Missing Timesheets: {102}
Invalid IDs: {500}
Report: ['REMINDER: Staff #102 (IT)']
Variant 9: Server Health Monitor
You are a Systems Administrator. You have a “Configuration Config” listing all servers that should be running and an “Active Ping List” of IP addresses that are currently responding. You need to identify which servers have crashed.
Write a program with the following three functions:
load_server_config(config_list):- Accepts a list of dictionaries:
{'ip_address': str, 'hostname': str}. - Returns a Dictionary where keys are
ip_addressand values arehostname.
- Accepts a list of dictionaries:
check_network_status(config_dict, active_ips):- Accepts the config dictionary and a list of strings (active IP addresses).
- Returns two Sets:
offline_servers: IPs in the config but NOT active.rogue_devices: IPs active but NOT in the config.
create_outage_alert(config_dict, offline_set):- Accepts the config dictionary and the set of offline IPs.
- Uses a List Comprehension to create a list of strings.
- Format:
"CRITICAL: [Hostname] is DOWN ([IP])" - Return the list sorted alphabetically by Hostname.
Testing Inputs
config = [
{'ip_address': "192.168.1.5", 'hostname': "Database-01"},
{'ip_address': "192.168.1.6", 'hostname': "Web-01"},
{'ip_address': "192.168.1.7", 'hostname': "Cache-01"}
]
pings = ["192.168.1.6", "192.168.1.7", "10.0.0.1"]
Expected Output
Offline Servers: {'192.168.1.5'}
Rogue Devices: {'10.0.0.1'}
Report: ['CRITICAL: Database-01 is DOWN (192.168.1.5)']
Variant 10: Election Turnout Analyzer
You are working for an election commission. You have a “Voter Registry” of all registered citizens and a “Ballot Box Log” of Voter IDs that were processed today. You need to identify which registered voters did not cast a ballot.
Write a program with the following three functions:
build_voter_map(registry_list):- Accepts a list of dictionaries:
{'voter_id': int, 'precinct': str}. - Returns a Dictionary where keys are
voter_idand values areprecinct.
- Accepts a list of dictionaries:
audit_turnout(voter_map, cast_ballots):- Accepts the voter map dictionary and a list of integers (IDs of cast ballots).
- Returns two Sets:
did_not_vote: IDs in the registry but NOT in the ballot log.invalid_ballots: IDs in the ballot log but NOT in the registry.
format_abstentions(voter_map, non_voter_set):- Accepts the voter map and the set of non-voter IDs.
- Uses a List Comprehension to create a list of strings.
- Format:
"NO VOTE: ID #[ID] (Precinct: [Precinct])" - Return the list sorted numerically by Voter ID.
Testing Inputs
registry = [
{'voter_id': 1001, 'precinct': "North District"},
{'voter_id': 1002, 'precinct': "South District"},
{'voter_id': 1003, 'precinct': "West District"}
]
ballots = [1001, 1003, 5555]
Expected Output
Did Not Vote: {1002}
Invalid Ballots: {5555}
Report: ['NO VOTE: ID #1002 (Precinct: South District)']
Variant 11: Parking Permit Enforcer
You manage a reserved parking lot for a university. You have a “Permit Database” of license plates authorized to park and a “Scanner Log” of license plates currently detected in the lot by cameras. You need to find which authorized spots are empty.
Write a program with the following three functions:
create_permit_index(authorized_list):- Accepts a list of dictionaries:
{'plate_num': str, 'owner_name': str}. - Returns a Dictionary where keys are
plate_numand values areowner_name.
- Accepts a list of dictionaries:
scan_lot(permit_index, current_plates):- Accepts the permit index and a list of strings (scanned plates).
- Returns two Sets:
unused_permits: Plates in the database but NOT currently in the lot (empty spots).violators: Plates in the lot but NOT in the database (illegal parking).
report_empty_spots(permit_index, unused_set):- Accepts the permit index and the set of unused permit plates.
- Uses a List Comprehension to create a list of strings.
- Format:
"EMPTY SPOT: Reserved for [Name] ([Plate])" - Return the list sorted alphabetically by the Owner’s Name.
Testing Inputs
permits = [
{'plate_num': "ABC-123", 'owner_name': "Dr. House"},
{'plate_num': "XYZ-789", 'owner_name': "Prof. X"},
{'plate_num': "LMN-456", 'owner_name': "Sherlock"}
]
in_lot = ["ABC-123", "LMN-456", "BAD-CAR"]
Expected Output
Unused Permits: {'XYZ-789'}
Violators: {'BAD-CAR'}
Report: ['EMPTY SPOT: Reserved for Prof. X (XYZ-789)']
Variant 12: Wildlife Conservation Tracker
You are a zoologist. You have a “Tagged Animals” catalog of animals with microchips and a “Camera Trap Log” of chip IDs detected near a watering hole today. You need to find which animals have not been seen.
Write a program with the following three functions:
catalog_animals(tag_data):- Accepts a list of dictionaries:
{'chip_id': str, 'species': str}. - Returns a Dictionary where keys are
chip_idand values arespecies.
- Accepts a list of dictionaries:
process_sightings(animal_catalog, detected_chips):- Accepts the animal catalog and a list of strings (detected chip IDs).
- Returns two Sets:
unseen_animals: IDs in the catalog but NOT detected.unknown_signals: IDs detected but NOT in the catalog.
alert_missing(animal_catalog, unseen_set):- Accepts the animal catalog and the set of unseen IDs.
- Uses a List Comprehension to create a list of strings.
- Format:
"NOT SEEN: [Species] (ID: [Chip])" - Return the list sorted alphabetically by Species.
Testing Inputs
tags = [
{'chip_id': "WOLF-01", 'species': "Grey Wolf"},
{'chip_id': "BEAR-09", 'species': "Brown Bear"},
{'chip_id': "DEER-55", 'species': "Elk"}
]
sightings = ["WOLF-01", "DEER-55", "UFO-99"]
Expected Output
Unseen Animals: {'BEAR-09'}
Unknown Signals: {'UFO-99'}
Report: ['NOT SEEN: Brown Bear (ID: BEAR-09)']
This content will be available starting January 07, 2026.