← ACARA Digital Technologies Years 9–10

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.

Understanding Frequency analysis in ACARA Digital Technologies Years 9–10

What it does: This code finds the ciphertext letter with the highest count and guesses that it stands for E. Frequency analysis counts letters. The most common ciphertext letters are matched to common English letters. A substitution cipher swaps letters but keeps the pattern. A common letter stays common after encryption. Only A and I are common one-letter English words. Guessing short words helps confirm the key.

Common mistakes: The string is missing its closing quote. It should be cipher = "KHOOR ZRUOG" so the ciphertext can be counted. Frequency analysis needs the MOST common ciphertext letter to match with E. The method is most_common(1). There is no least_common method.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 860–875) and word search (Modules 860–944).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
What does frequency analysis count in a ciphertext?
How often each letter appearsHow many words are in the message
Matches
Ciphertext letter Q is the least common, so Q must be E.
↓
E is the most common letter in English, so the most common ciphertext letter is the best guess for E, not the least common.
Applying
Meanings
Term
frequency analysis
Meaning
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.
Practice
cipher = "WKLV LV D VHFUHW"
Testing
Gaps
ch in cipher:
Check Answer
Spots
1cipher = "KHOOR ZRUOG
2letter = "O"

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Lion's Mane Jellyfish' badge — Set Operator, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. What does frequency analysis count in a ciphertext?
A. How many words are in the message
B. How often each letter appears ✓
Frequency analysis counts letters. The most common ciphertext letters are matched to common English letters.
2. In a long English message, which letter is usually the most common?
A. Z
B. E ✓
E is the most common letter in English. Z is one of the rarest.
3. A ciphertext has the letter X far more often than any other letter. What is a good first guess?
A. X stands for E ✓
B. X stands for Z
The most common ciphertext letter probably stands for the most common plaintext letter, which is E.
4. Why does frequency analysis work on a substitution cipher?
A. Each plaintext letter always becomes the same ciphertext letter, so the letter pattern stays ✓
B. The cipher hides every letter pattern completely
A substitution cipher swaps letters but keeps the pattern. A common letter stays common after encryption.
5. Which method gives a codebreaker a way to check a guess about a short word?
A. Guess that a one-letter word is A or I ✓
B. Guess that every short word is the same
Only A and I are common one-letter English words. Guessing short words helps confirm the key.

Match the Pairs

frequency analysis → Counting how often each letter appears in ciphertext and matching the most common ones to common English letters like E to crack a substitution cipher
counts = {"Q": 14, "X": 3, "M": 9} → A tally of how many times each ciphertext letter appears, where Q is the most common and so is probably E
E is the most common letter in English, so the most common ciphertext letter is probably E → most_common = max(counts, key=counts.get) guess = {most_common: "E"}
Counting letter frequencies means going through the ciphertext and adding 1 to a tally for each letter → for letter in ciphertext: counts[letter] = counts.get(letter, 0) + 1
Ciphertext letter Q is the least common, so Q must be E. → E is the most common letter in English, so the most common ciphertext letter is the best guess for E, not the least common.
A substitution cipher hides letter patterns, so frequency analysis cannot crack it. → A substitution cipher keeps letter patterns because each plaintext letter always becomes the same ciphertext letter, so the frequencies still show.

Key Term

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.

Fill in the Blanks

1. counts = {} for ch in cipher: counts[ch] = counts.get(ch, 0) + 1
Hint: Type the keyword that repeats the code once for every letter in the ciphertext.
2. counts = {"X": 9, "Q": 4, "M": 2} top = max(counts, key=counts.get) print(top)
Hint: Type the built-in function that picks the letter with the biggest count.
3. top = "X" shift = ord(top) - ord("E") print(shift)
Hint: Type the letter that is the most common in English text, which the top ciphertext letter probably stands for.
4. word = "X" if len(word) == 1: print("Try A or I")
Hint: Type the number of letters in a word that could only be A or I.
5. guess = {"X": "E"} for ch in cipher: print(guess.get(ch, "_"), end="")
Hint: Type the name of the variable that stores the guessed letter matches.

Spot the Error

Question 1
A cipher = "KHOOR ZRUOG
B letter = "O"
C n = cipher.count(letter)
D print(letter, n)
Line A — The string is missing its closing quote. It should be cipher = "KHOOR ZRUOG" so the ciphertext can be counted.
Question 2
A from collections import *
B counts = Counter("KHOOR")
C top = counts.least_common(1)
D print(top)
Line C — Frequency analysis needs the MOST common ciphertext letter to match with E. The method is most_common(1). There is no least_common method.
Question 3
A top = "H"
B shift = ord("E") - ord(top)
C print(shift)
Line B — The shift is the ciphertext letter minus the plain letter E. The subtraction is reversed, giving -3 instead of 3. It should be ord(top) - ord("E").
Question 4
A d = {}
B for c in "KHOOR":
C d[c] = 1
D print(d)
Line C — This resets each letter's count to 1 every time, so repeated letters like O are never counted properly. It should add 1 to the old count: d[c] = d.get(c, 0) + 1.
Question 5
A d = {"K": 1, "H": 1, "O": 2}
B best = "K"
C for c in d:
D if d[c] < d[best]:
E best = c
Line D — Using < picks the least common letter. To find the most common ciphertext letter, the test must be d[c] > d[best].

Student with a class code? Join your class →