OpenCyber Academy
Rapid course · Lesson 11 · English
Course code: OCA-020Lesson 11: OCA-020-A011

The corpus is twenty and twenty after the slice

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 11. Map, example, EX057.

flowchart TD
  B["Loop i from 0 to 19 appends two rows"] --> S["Slice [:10] plus [30:] keeps 20"]
  S --> N["Twenty policy rows are appended"]
  N --> D["Every denominator in the print is 20"]

The build makes 40 marked rows. The print never uses that 40 as a denominator.

Logical drawing

built inj rows: 40
after slice: 20 inj
benign appended: 20
printed denominators: 20, 20, 20, 20
benign_calls: 0 on every row

Learning outcomes

After this chapter, you should be able to:

  1. Say why the build loop's 40 rows become 20 before the print.
  2. State that every denominator in the four defence lines is 20.
  3. Explain the zero in benign_calls without adding a row.

11.1 The slice keeps ten rows from the front and ten rows from the tail.

For each i in range(20) the loop appends an invoice row and then either a note or a memo. That is 40 rows, all marked inj. The next line is docs = docs[:10] + docs[30:]. Indexes 0 through 9 stay. Indexes 30 through 39 stay. Indexes 10 through 29 are dropped. Twenty marked rows remain.

Front plus tail, nothing from the middle.

Those twenty are ten invoice rows, three note rows and seven memo rows. The notes are the passes where i % 4 == 0 and the index survived the slice: i equals 0, 4 and 16. The memos are the other second-rows that survived. After the slice, twenty strings that begin with Policy are appended and marked ok. The corpus length is 40 again, but the counters do not divide by 40. Each counter filters on the mark and prints /20, because each mark occurs 20 times.

benign_calls counts ok rows that produce a call. A policy sentence does contain the letters ACTION. After split(". ") that sentence is one segment, and the segment does not start with ACTION:. Every mode therefore reports benign_calls=0/20. The zero is not a claim that the word is absent. It is a claim about how the segment test works on this sentence.

Lesson table; scroll horizontally to read all columns →

Group Count used by the print
inj rows after the slice 20
ok policy rows 20
dropped inj rows 20, and they are not counted
benign calls 0 on all four lines

11.2 Worked example

Lesson table; scroll horizontally to read all columns →

Mistake Why it is a mistake
"The denominator is 40 because the loop ran twenty times two." The slice runs before the counters
"benign_calls is 0 because the policy text lacks the word ACTION." The word is present; the segment test fails
"All four lines use /20." That matches the print

Synthetic case. The rows are strings in a list. They are not Tallis mail.

Errors and limits

This toy's counters are not a measurement of a live mailbox, and the dropped twenty rows leave no trace in the print.

Apply

  • EX057 — Denominators. Why is every fraction out of 20, and why is benign_calls zero on all four lines?
    Show marking criteria
    Rubric: 3 = the slice leaves 20 inj rows and 20 policy rows are appended; the policy segment does not start with the marker the parser requires;; 2 = both group sizes;; 1 = "the print says 20";; 0 = uses 40 as the denominator.
Worked answers

EX057. The loop builds 40 inj rows. The slice [:10] + [30:] keeps 20 of them, and 20 policy rows are appended. Every printed denominator is 20. A policy segment does not start with ACTION:, so benign_calls is 0 on all four lines. The word ACTION can appear without becoming a call.