Objective & prerequisites
Choose a data structure that preserves the meaning of your analysis. Before starting: basic Python functions, dictionaries, loops, JSON and terminal use. Complete the earlier Git/API/testing workshops if these are unfamiliar. Download and extract the kit into a new practice folder, then open a terminal in the software-kit folder. Python 3.10+ is required; the reference uses only the standard library. Work with the supplied fictional data. These free companion lessons do not change protected course access or award progress or certificates.
python3 --version
python3 -m unittest discover -s tests -vUnderstand the concept
A list preserves sequence and permits duplicates. A dictionary maps unique keys to values; repeated assignment replaces a value unless you check first. A set supports distinct membership but loses repeated occurrences and is not a reliable presentation ordering. A deque supports efficient additions and removals at both ends and is useful for a first-in-first-out work queue. Structure choice is part of the data contract: converting source records to a set cannot resolve two conflicting versions of one business event. A unique-ID dictionary makes lookup convenient, but you must reject or explicitly reconcile duplicates before insertion.
Worked example
The fixture has four source rows: F01 web 12000, F02 store 8000, F03 web 15000, F04 store 5000. A list preserves all four input observations. Ledger indexes four IDs and calculates web 27000, store 13000, total 40000 cents. The invalid fixture repeats F01 with conflicting information. It must fail; allowing the later assignment to win would turn an evidence conflict into an undocumented correction.
from collections import deque
queue = deque(["F01", "F02", "F03", "F04"])
assert queue.popleft() == "F01"
assert len(queue) == 3Try it yourself
Build a list of the four IDs, a set of channels and a dictionary mapping ID to cents. Check for duplicates before constructing the dictionary. Use collections.deque to process IDs in input order. State what would be lost if you used a set for the queue. Write your expected outcome before running your implementation. Keep the supplied solution unchanged so that you can compare your own reasoning with it.
Worked solution
The ID list is F01,F02,F03,F04; the channel set contains web and store with no display-order guarantee. The ID mapping has four entries. The queue removes F01 first using popleft(). A set would remove duplicate occurrences and would not preserve the intended FIFO sequence. See solutions/worked-solutions.txt for a complete runnable answer.
Knowledge check
Can a four-entry dictionary prove the original file contained exactly four records?
Check and explain
No. Duplicate keys may have been overwritten before you counted. Preserve and validate the source list, then reconcile source count with the unique-key index.
Evidence & common mistakes
Record the exact command, Python version, observed output and one rejected input. Explain what each check establishes and what it leaves untested. Do not remove validation merely to obtain a passing result. A local passing suite is evidence for these fixtures, not proof of production readiness. Credit the teaching reference and distinguish your own changes. The kit includes an exercise worksheet, a separate worked-solutions document, an API contract, expected results and a capstone rubric.
Authoritative reference
— official reference for the underlying interface. Lesson prose and fictional order examples are original. The teaching HTTP service is loopback-only, stateless and not suitable for production or uploading as a running Aruba service. No cloud account, paid API or registration is required.
Try the activity before reading its reference. Keep your sources, commands and assumptions with your work. Companion activities are unsaved self-practice and do not award a certificate or change lesson progress.