<a id="ch-10"></a>

## Chapter 10 — The else branch sends nothing

<!-- open-cyber-academy:lesson-figures:start ch-10 -->
### Lesson map

Lesson 10. Map, example, EX056.

```mermaid
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

```text
imports
  ipaddress only
calls that are absent
  socket, DNS, connect
else runs for
  192.0.2.130
  198.51.100.7
```
<!-- open-cyber-academy:lesson-figures:end ch-10 -->

### Learning outcomes

After this chapter, you should be able to:

1. Name the only import.
2. Say which two lines come from the `else`.
3. 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.

| 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

| 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? *Rubric:* 3 = `ipaddress` only; `.130` and `198.51.100.7` take the `else`; 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.

<!-- open-cyber-academy:chapter-navigation:start ch-10 -->
### Continue studying — lesson 10 (chapter 10 of 20)

[← Chapter 09](#ch-09) · [Course chapter index](../SUBJECTS.md) · [Chapter 11 →](#ch-11)

Continue to the next authored lesson.
<!-- open-cyber-academy:chapter-navigation:end -->

## Worked answers

<a id="answer-ex056"></a>
**EX056.** The only import is `ipaddress`. The `else` covers `192.0.2.130` and `198.51.100.7`. That branch prints and does not contact a host.
