← ACARA Digital Technologies Years 5–6

Encoding and decoding a word with a letter-number code

To encode a word, swap each letter for its number in the code, so with A=1, B=2 and C=3, CAB becomes 3 1 2. To decode it, swap each number back for its letter.

Understanding Encoding and decoding a word with a letter-number code in ACARA Digital Technologies Years 5–6

What it does: B is 2, A is 1 and D is 4, so the name BAD is encoded as 2 1 4. Decoding 3 1 2 gives C, A, B. This matches the original word CAB, so the encoding was correct. Swap each letter for its number: B is 2, A is 1 and D is 4, so BAD becomes 2 1 4. Encoding turns letters into numbers. Swapping numbers back into letters is decoding. E is 5 and D is 4, and the order of the letters stays the same, so ED becomes 5 4. The 0 stands for a space, so the message has two words: BAD and CAD.

Common mistakes: In the code, B=2, not 3. Line 2 should be B -> 2, so that BAD encodes to 2 1 4. The code says D=4, but line 1 says D=3. The later lines use 4, so line 1 should say D=4.

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 73–84) and word search (Modules 73–104).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Using A=1, B=2, C=3, D=4, how do you encode the word BAD?
1 2 42 1 4
Matches
CAB = 3 2 1
↓
The numbers are in the wrong order. A should be 1 and B should be 2, so CAB is 3 1 2, not 3 2 1.
Applying
Meanings
Term
encode
Meaning
To encode a word, swap each letter for its number in the code, so with A=1, B=2 and C=3, CAB becomes 3 1 2. To decode it, swap each number back for its letter.
Practice
Key: A=1, B=2, C=3, D=4, E=5
Testing
Gaps
encode("BAD") = 2 1
Check Answer
Spots
1Code: A=1, B=2, C=3, D=4
2B -> 3

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

The 'Butterfly' badge — Branch Hopper, 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. Using A=1, B=2, C=3, D=4, how do you encode the word BAD?
A. 2 1 4 ✓
B. 1 2 4
Swap each letter for its number: B is 2, A is 1 and D is 4, so BAD becomes 2 1 4.
2. Using A=1, B=2, C=3, D=4, what word does 3 1 4 decode to?
A. CAD ✓
B. DAC
To decode, swap each number back for its letter: 3 is C, 1 is A and 4 is D. The word is CAD.
3. Which describes what it means to encode a word with a letter-number code?
A. Swap each letter for its number ✓
B. Swap each number for its letter
Encoding turns letters into numbers. Swapping numbers back into letters is decoding.
4. With A=1, B=2, C=3, D=4, E=5, how do you encode the name ED?
A. 4 5
B. 5 4 ✓
E is 5 and D is 4, and the order of the letters stays the same, so ED becomes 5 4.
5. A message is encoded as 2 1 4 0 3 1 4, where 0 means a space between words. Which is the decoded message (A=1, B=2, C=3, D=4)?
A. BADCAD
B. BAD CAD ✓
The 0 stands for a space, so the message has two words: BAD and CAD.

Match the Pairs

CAB = 3 1 2 → Encoding the word CAB by swapping each letter for its number when A=1, B=2 and C=3
2 1 3 = BAC → Decoding the numbers 2 1 3 by swapping each number back for its letter when A=1, B=2 and C=3
Encoding a name: swap each letter for its number, using A=1, B=2, C=3, D=4 and so on → BAD = 2 1 4
Checking by decoding: turn the numbers back into letters to see if you get the original word → 3 1 2 = CAB, so the code is right
CAB = 3 2 1 → The numbers are in the wrong order. A should be 1 and B should be 2, so CAB is 3 1 2, not 3 2 1.
A=1, B=2, C=3: 2 1 3 decodes to ABC → The numbers were put in order instead of being decoded one by one. 2 is B, 1 is A and 3 is C, so the word is BAC.

Key Term

encode
To encode a word, swap each letter for its number in the code, so with A=1, B=2 and C=3, CAB becomes 3 1 2. To decode it, swap each number back for its letter.

Fill in the Blanks

1. Key: A=1 B=2 C=3 D=4 E=5 encode("BAD") = 2 1 4
Hint: Type the number the key gives to the last letter.
2. Key: A=1 B=2 C=3 D=4 E=5 decode(3 1 4 5) = C A D E
Hint: Type the letter that matches the third number in the key.
3. Key: A=1 B=2 C=3 D=4 E=5 space=0 encode("A BE") = 1 0 2 5
Hint: Type the number the key uses to mark a space between words.
4. Key: A=1 B=2 C=3 D=4 E=5 encode("CAB") = 3 1 2
Hint: Type the function name that swaps letters for numbers.
5. Key: A=1 B=2 C=3 D=4 E=5 encode("ACE") = 1 3 5 decode(1 3 5) = "ACE"
Hint: Type the function name that checks the code by swapping numbers back to letters.

Spot the Error

Question 1
A Code: A=1, B=2, C=3, D=4
B B -> 3
C A -> 1
D D -> 4
E BAD = 2 1 4
Line B — In the code, B=2, not 3. Line 2 should be B -> 2, so that BAD encodes to 2 1 4.
Question 2
A Encode DAD with A=1, D=3
B D -> 4
C A -> 1
D D -> 4
E DAD = 4 1 4
Line A — The code says D=4, but line 1 says D=3. The later lines use 4, so line 1 should say D=4.
Question 3
A Decode 3 1 2 (A=1, B=2, C=3)
B 3 -> B
C 1 -> A
D 2 -> B
E Message: CAB
Line B — To decode, swap each number back to its letter. 3 is C, not B. Line 2 should be 3 -> C.
Question 4
A Encode HI MOM, A=1 to Z=26
B HI -> 8 9
C MOM -> 13 15 14
D Put / between the words
E 8 9 / 13 15 13
Line C — M is 13, O is 15 and M is 13 again. The last number should be 13, so line 3 should be MOM -> 13 15 13.
Question 5
A Encode ZOE with A=1 to Z=26
B Z -> 25
C O -> 15
D E -> 5
E ZOE = 26 15 5
Line B — Z is the 26th letter, so Z=26, not 25. Line 2 should be Z -> 26.

Student with a class code? Join your class →