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

## Chapter 6 — The flag is an or of two tests

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

Lesson 06. Map, example, EX052.

```mermaid
flowchart TD
  N["One dependency key"] --> A{"len of names greater than 1?"}
  N --> B{"Does the key contain Sam?"}
  A --> F["SINGLE POINT OF FAILURE if either is true"]
  B --> F
  F --> Q{"Does this print contain ok?"}
  Q -->|No| K["The else branch is unused"]
```

Either test is enough. This run takes neither line to `ok`.

### Logical drawing

```text
condition
  len(names) > 1 or "Sam" in the key
true
  SINGLE POINT OF FAILURE
false, unused here
  ok
this print
  two failure lines
  zero ok lines
```
<!-- open-cyber-academy:lesson-figures:end ch-06 -->

### Learning outcomes

After this chapter, you should be able to:

1. Name the two tests in the flag expression.
2. Say which test fires for each printed line.
3. Refuse an `ok` line that this run does not contain.

### 6.1 One true test selects the failure label. The other test still exists.

The flag line is a conditional expression. The failure label is chosen when `len(names) > 1` is true or when `"Sam" in d` is true. Otherwise the label is the literal `ok`. The inbox key has two names, so the length test alone selects the failure label. The form key has one name, so the length test is false there, and the substring test is what selects the failure label. Both lines print `SINGLE POINT OF FAILURE` for different reasons. The word `or` means the script does not require both tests to be true.

This output contains no `ok` line. A dependency whose name list had length one, and whose key did not contain `Sam`, would print `ok`. No such key is created by these four tuples, so the else branch is real code and an absent result. Adding an `ok` line to "show the other branch" would invent a dependency.

| Key in this print | Test that fires |
|---|---|
| coordinator inbox | Length is 2 |
| form owner Sam | The key contains `Sam` |
| An `ok` line | Not produced by this run |

### 6.2 Worked example

| Offered reading | What the expression did | Decision |
|---|---|---|
| Both printed lines use the failure label | Each key made one test true | Keep |
| The inbox line does not need the substring | Length 2 is enough | Keep |
| "Both tests failed, so the label is a score." | `or` is not a sum | Refuse |
| "The script printed ok for advisories." | Advisories are not a `deps` key | Refuse |

> **Synthetic case.** Two failure lines are the whole flag result.

### Errors and limits

Do not insert an `ok` row in order to illustrate the unused branch.

### Apply

- **EX052 — Two tests.** Why do both dependency lines say `SINGLE POINT OF FAILURE`, and does this print contain `ok`? *Rubric:* 3 = the inbox line fails the length test; the form line fails the substring test; `or` does not add the tests; this print has no `ok` line;; 2 = each line has its own true test and `ok` is absent;; 1 = one line;; 0 = none.

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

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

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

## Worked answers

<a id="answer-ex052"></a>
**EX052.** The inbox line fails because its name list has length 2. The form line fails because the key contains Sam. `or` does not add the tests. This print has no `ok` line.
