Lesson map
Lesson 10. Map, example, EX056.
flowchart TD
E["else assigns a string"] --> P["print writes the line"]
P --> N["No socket, no DNS, no packet"]
N --> K["Two lines use that else"]
The else is live code. Its only effect is a line of text.
Logical drawing
imports
ipaddress only
calls that are absent
socket, DNS, connect
else runs for
192.0.2.130
198.51.100.7
Learning outcomes
After this chapter, you should be able to:
- Name the only import.
- Say which two lines come from the
else. - Refuse a claim that the script probed those addresses.
10.1 A verdict string is not a packet.
The file imports ipaddress and nothing else. ip_address and ip_network parse text into objects in memory. The else stores the words OUT OF SCOPE - do not test and the print writes them. There is no socket, no name lookup, and no connection. The comment at the top says no network traffic is sent. The branch structure agrees with that comment: every path ends at print.
Two of the four lines take the else. That means the branch is used. It is not a leftover. Using it still does not contact 192.0.2.130 or 198.51.100.7. A later reader who "finishes the lab" by reaching those addresses has left the file.
Lesson table; scroll horizontally to read all columns →
| Path | Lines that take it | Leaves the machine? |
|---|---|---|
if excluded |
The payroll line | No |
elif in network |
The .5 line |
No |
else |
.130 and 198.51.100.7 |
No |
10.2 Worked example
Lesson table; scroll horizontally to read all columns →
| Offered claim | What the file contains | Decision |
|---|---|---|
| "The miss lines are local prints." | print of a string |
Keep |
| "The else is dead, so those rows were typed by hand." | Two inputs take it | Refuse |
| "Out of scope means the script checked the host and found it down." | No such check | Refuse |
Synthetic case. The classroom pack never leaves the interpreter.
Errors and limits
Do not add a network call so the refusal "really" checks a host.
Apply
- EX056 — No packet. Which import does the scope script use, which lines take the
else, and does that branch contact a host?Show marking criteria
Rubric: 3 =ipaddressonly;.130and198.51.100.7take theelse; the branch prints and does not contact a host;; 2 = the miss lines are prints and no packet is sent;; 1 = one fact;; 0 = none.