← ACARA Digital Technologies Years 7–8

Substitution cipher

A cipher that swaps each letter for a different letter or symbol using a key table, like a scrambled alphabet. It is not a simple shift, and the table is used in reverse to decrypt.

Understanding Substitution cipher in ACARA Digital Technologies Years 7–8

What it does: The cipher letters Q, E and Z are looked up backwards to get A, C and T, which undoes the encryption. A moves to Q, B moves to W and C moves to E. The distances are all different, so this is not a simple shift. A substitution cipher uses a key table. A simple shift is what a Caesar cipher does, and the Caesar cipher is only one special kind of substitution. Look up each letter in the table: C becomes E, A becomes Q and B becomes W, which gives EQW. QWE is the encrypted form of ABC.

Common mistakes: This prints the plain letter C again, so nothing is substituted. To encrypt, take the letter at the same position in the key row: print(key[pos]). BCDEA is just the alphabet shifted by one, which is a Caesar shift. A substitution cipher needs a scrambled key such as "XQMZP".

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 696–726) and word search (Modules 696–770).

Take this worksheet further — free with Cloodit

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

Learning
Duo
A substitution cipher uses a scrambled alphabet as its key. Which description fits it best?
Each letter is swapped for a different letter using a key tableEvery letter is moved along by the same number of places
Matches
key = QWERTYUIOPASDFGHJKLZXCVBNN
↓
The key repeats N and leaves out M. Two plain letters would share one cipher letter, so decrypting would be ambiguous.
Applying
Meanings
Term
substitution cipher
Meaning
A cipher that swaps each letter for a different letter or symbol using a key table, like a scrambled alphabet. It is not a simple shift, and the table is used in reverse to decrypt.
Practice
plain ← "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Testing
Gaps
= "QWERTYUIOPASDFGHJKLZXCVBNM"
Check Answer
Spots
3pos = plain.index("C")
4print(plain[pos])

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

The 'Giant Squid' badge — Nested Navigator, 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. A substitution cipher uses a scrambled alphabet as its key. Which description fits it best?
A. Each letter is swapped for a different letter using a key table ✓
B. Every letter is moved along by the same number of places
A substitution cipher uses a key table. A simple shift is what a Caesar cipher does, and the Caesar cipher is only one special kind of substitution.
2. Here is a key table: A→Q, B→W, C→E. How is the word CAB encrypted?
A. QWE
B. EQW ✓
Look up each letter in the table: C becomes E, A becomes Q and B becomes W, which gives EQW. QWE is the encrypted form of ABC.
3. To decrypt a message made with a substitution cipher, what do you do with the key table?
A. Use the table the same way again to encrypt the ciphertext a second time
B. Use the table in reverse, finding each cipher letter and reading the plain letter ✓
Decrypting means going backwards. Find each ciphertext letter in the table and write down the plain letter it came from.
4. Using the table A→Q, B→W, C→E, what does the ciphertext WQE decrypt to?
A. BAC ✓
B. CAB
Reverse the table: W came from B, Q came from A and E came from C, so the message is BAC.
5. Which key would a substitution cipher use?
A. A scrambled alphabet such as QWERTYUIOPASDFGHJKLZXCVBNM ✓
B. A single number such as 3
A substitution key is a table that matches every letter to a different one. A single number is the key for a Caesar shift cipher.

Match the Pairs

key = QWERTYUIOPASDFGHJKLZXCVBNM → A scrambled alphabet key: A becomes Q, B becomes W, C becomes E, and so on for all 26 letters
DOG -> RGU → Encrypting DOG with the key table: D becomes R, O becomes G and G becomes U
To decrypt, use the key table in reverse: find the cipher letter, then read off the plain letter it replaced → Q -> A, E -> C, Z -> T
Each letter swaps for a different letter with no fixed shift, so it is not a Caesar shift → A -> Q, B -> W, C -> E
key = QWERTYUIOPASDFGHJKLZXCVBNN → The key repeats N and leaves out M. Two plain letters would share one cipher letter, so decrypting would be ambiguous.
Decrypt Z: Z -> M → The table was used forwards. M is what Z encrypts to, not what Z decrypts to.

Key Term

substitution cipher
A cipher that swaps each letter for a different letter or symbol using a key table, like a scrambled alphabet. It is not a simple shift, and the table is used in reverse to decrypt.

Fill in the Blanks

1. alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" key = "QWERTYUIOPASDFGHJKLZXCVBNM"
Hint: Type the variable name that holds the scrambled alphabet used as the key table.
2. alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" key = "QWERTYUIOPASDFGHJKLZXCVBNM" cipher = key[alphabet.index("A")]
Hint: Type the method that finds the position of a letter in the normal alphabet, so the matching key letter can be picked.
3. alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" key = "QWERTYUIOPASDFGHJKLZXCVBNM" plain = alphabet[key.index("Q")]
Hint: To decrypt, the table is used in reverse. Type the variable that gives back the original letter.
4. coded = "" for letter in message: coded += key[alphabet.index(letter)]
Hint: Type the keyword that makes the loop go through each letter of the message.
5. table = {"A": "Q", "B": "W", "C": "E"} reverse = {v: k for k, v in table.items()} print(reverse["W"])
Hint: Type the dictionary method that gives each pair, so the table can be flipped for decrypting.

Spot the Error

Question 1
A plain = "ABCDE"
B key = "XQMZP"
C pos = plain.index("C")
D print(plain[pos])
Line D — This prints the plain letter C again, so nothing is substituted. To encrypt, take the letter at the same position in the key row: print(key[pos]).
Question 2
A plain = "ABCDE"
B key = "BCDEA"
C out = ""
D for ch in "BAD":
E out += key[plain.index(ch)]
Line B — BCDEA is just the alphabet shifted by one, which is a Caesar shift. A substitution cipher needs a scrambled key such as "XQMZP".
Question 3
A key = {"A": "Q", "B": "Q"}
B out = key["A"] + key["B"]
C print(out)
Line A — Two plain letters now share the cipher letter Q. The receiver could not tell which one it came from when decrypting. Each letter needs its own cipher letter, e.g. "B": "W".
Question 4
A enc = {"A": "Q", "B": "W"}
B dec = {"Q": "A", "W": "B"}
C print(enc["Q"], enc["W"])
Line C — enc maps plain letters to cipher letters, so looking up Q and W in it fails. To decrypt, use the reversed table: print(dec["Q"], dec["W"]).
Question 5
A FOR each word in message
B find it in the plain row
C replace with the key letter
D END FOR
Line A — A substitution cipher swaps one letter at a time using the key table, not whole words. The loop should be FOR each letter in message.

Student with a class code? Join your class →