OpenCyber Academy
Rapid course · Lesson 8 · English
Course code: OCA-018Lesson 08: OCA-018-A008

The independent line is a list repr

Open, free learning for anyone who wants to protect people and technology. No account is required to read this text or its worked answers.

Lesson map

Lesson 08. Map, example, EX054.

flowchart TD
  S["Four tuples"] --> E{"Is needs empty?"}
  E -->|Yes| L["One name in a Python list"]
  E -->|No| D["A deps key instead"]
  L --> P["Brackets and single quotes"]

Empty needs select the name. The print then shows Python's list form.

Logical drawing

kept
  National charity advisories
printed form
  ['National charity advisories']
excluded
  any tuple whose needs list is non-empty
not shown
  the word web page

Learning outcomes

After this chapter, you should be able to:

  1. State the test if not needs.
  2. Read the brackets and quotes as Python's list form.
  3. Refuse a channel word the line does not contain.

8.1 Empty means independent. The brackets are part of the print.

The last statement builds a list of names whose needs list is empty. if not needs is true for [] and false for a list that holds a string. Only National charity advisories has an empty needs list, so the result has one element. print of a list uses Python's representation: square brackets, a single-quoted string, and no extra label invented by Sam. The line begins with the words independent sources: because that literal is in the format string. The brackets are not a TLP mark.

The channel web page is the second field of the tuple. The comprehension keeps n and drops the channel. A reader cannot recover web page from the independent line. The other three sources are absent here because each has a needs list, not because the script judged them unimportant. Fixing the inbox in prose does not move Donation platform notices onto this line. The embedded list still has one name.

Lesson table; scroll horizontally to read all columns →

Piece What it contributes
if not needs Selects an empty needs list
List representation Brackets and single quotes
The channel field Stored, not printed on this line
A later shared mailbox Does not edit the list

8.2 Worked example

Lesson table; scroll horizontally to read all columns →

Offered reading What the line shows Decision
One name, inside brackets and quotes The list representation Keep
The other three sources are absent Their needs lists are non-empty Keep
"The line says web page." The channel was not kept Refuse
"A shared mailbox removes the brackets." The print is unchanged Refuse

Synthetic case. One independent name is the whole list.

Errors and limits

Do not treat the brackets as a sharing label.

Apply

  • EX054 — List form. What does ['National charity advisories'] include, and why are the email sources absent from it?
    Show marking criteria
    Rubric: 3 = one name in Python's list form; email sources have a non-empty needs list; the channel word is not on the line; a later mailbox fix does not edit the print;; 2 = the brackets hold one empty-needs name;; 1 = the name only;; 0 = none.
Worked answers

EX054. The brackets hold one name, National charity advisories, because its needs list is empty. Email sources have a non-empty needs list. The channel word is not on the line, and a later mailbox fix does not edit the print.