Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1frequency analysis | AA tally of how many times each ciphertext letter appears, where Q is the most common and so is probably E | |
| 2counts = {"Q": 14, "X": 3, "M": 9} | BA substitution cipher keeps letter patterns because each plaintext letter always becomes the same ciphertext letter, so the frequencies still show. | |
| 3E is the most common letter in English, so the most common ciphertext letter is probably E | Cfor letter in ciphertext: counts[letter] = counts.get(letter, 0) + 1 | |
| 4Counting letter frequencies means going through the ciphertext and adding 1 to a tally for each letter | Dmost_common = max(counts, key=counts.get) guess = {most_common: "E"} | |
| 5Ciphertext letter Q is the least common, so Q must be E. | EE is the most common letter in English, so the most common ciphertext letter is the best guess for E, not the least common. | |
| 6A substitution cipher hides letter patterns, so frequency analysis cannot crack it. | FCounting how often each letter appears in ciphertext and matching the most common ones to common English letters like E to crack a substitution cipher |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
frequency analysis — Counting how often each letter appears in ciphertext and matching the most common ones to common English letters like E, to work out a substitution cipher's key.counts = {}
for ch in cipher:
counts[ch] = counts.get(ch, 0) + 1counts = {"X": 9, "Q": 4, "M": 2}
top = max(counts, key=counts.get)
print(top)top = "X"
shift = ord(top) - ord("E")
print(shift)word = "X"
if len(word) == 1:
print("Try A or I")guess = {"X": "E"}
for ch in cipher:
print(guess.get(ch, "_"), end="")