Lesson map
Lesson 05. Map, example, EX051.
flowchart TD
L["Four source tuples, written order"] --> D["deps grows by first sighting"]
D --> P["Two dependency lines, then the independent line"]
P --> Q{"Did a sort pick the inbox line?"}
Q -->|No| K["Keep the embedded print"]
The walk follows sources. Nothing in the file sorts the names.
Logical drawing
coordinator inbox: CCC alerts, Donation platform notices -> SINGLE POINT OF FAILURE
form owner Sam: Volunteer reports -> SINGLE POINT OF FAILURE
independent sources: ['National charity advisories']
Learning outcomes
After this chapter, you should be able to:
- Name the order
sourcesis written in. - Say why the inbox line prints before the form line.
- Refuse a print that leads with the national advisories.
5.1 Keys appear when they are first needed. Names append after that.
lab_sources.py stores four tuples. Each tuple is a source name, a channel, and a list of needs. The first tuple is CCC alerts, with the need coordinator inbox. The second is National charity advisories, with an empty needs list. The third is Donation platform notices, again needing coordinator inbox. The fourth is Volunteer reports, needing form owner Sam. The loop walks that written order. It never calls sorted.
The mapping starts blank.
A key opens at the earliest requirement.
Alerts open the mailbox key.
The donation-page record appends there, so the length is two.
The shared-form record opens the other key alone.
items() emits creation sequence.
Mailbox comes before the other key.
The web-page record adds no key.
Its title sits at the bottom because a later statement prints it.
A later decision to name a deputy is a sentence in the notes. It does not reorder these three lines.
Lesson table; scroll horizontally to read all columns →
| What the walk uses | What it does not use |
|---|---|
Position in sources |
An alphabetical sort |
| First sighting of a need | A severity score |
| Append, for a repeated need | A staff directory |
5.2 Worked example
Lesson table; scroll horizontally to read all columns →
| Offered result | What produced it | Decision |
|---|---|---|
| Inbox line, then form line, then the independent line | Insertion, then one extra print | Keep |
| CCC alerts before Donation platform notices | Append order inside the inbox list | Keep |
| "The script sorted by channel." | No sort is called | Refuse |
| "National advisories print first because they are safest." | That tuple is not a deps key |
Refuse |
Synthetic case. These three lines are the only source-lab output.
Errors and limits
Do not rebuild sources so that a preferred channel prints first.
Apply
- EX051 — List order. The print names the coordinator inbox, then form owner Sam, then the national advisories. May a preference for the independent source, or a later deputy, replace that order?
Show marking criteria
Rubric: 3 = no; the dependency lines follow first sighting; names append in source order; the independent line is the last print; do not sort the script;; 2 = the three lines stay and the deputy stays prose;; 1 = one line;; 0 = none.