← ACARA Digital Technologies Years 7–8

Padding binary with leading zeros

Extra 0s added at the left of a binary number to fill a fixed number of bits. They do not change its value: 101 and 00000101 both mean 5.

Understanding Padding binary with leading zeros in ACARA Digital Technologies Years 7–8

What it does: The zeros on the left add nothing to the place values, so 101 and 00000101 both equal 4 + 1 = 5. 65 in binary is 1000001, which is only 7 bits. Adding one leading zero makes a full 8-bit code, 01000001. Leading zeros are like writing 007 instead of 7. They fill space but the value stays the same. Fixed-length codes make it easy to know where one value ends and the next begins. Padding never makes the number bigger. Padding goes at the left, in front of the number. 11000000 would be 192, not 3. 101 already uses 3 bits, so you need 8 - 3 = 5 extra zeros on the left.

Common mistakes: Without the 0 in the format code, the number is padded with spaces instead of zeros. It should be "08b" so 5 becomes 00000101. Padding to a width of 3 leaves 101 unchanged. An 8-bit code needs zfill(8) to give 00000101.

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 128–152) and word search (Modules 69–152).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which is the 8-bit way to write the number 5 in binary?
0000010110100000
Matches
5 in 8 bits = 10100000
↓
The zeros were added on the right instead of the left. That changes the value to 160. Padding must go on the left: 00000101.
Applying
Meanings
Term
leading zeros
Meaning
Extra 0s added at the left of a binary number to fill a fixed number of bits. They do not change its value: 101 and 00000101 both mean 5.
Practice
5 = 101
Testing
Gaps
101 padded to 8 bits = 101
Check Answer
Spots
1n = 5
2bits = format(n, "8b")

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

The 'Cosmic Owl' badge — Comprehension Guru, 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. Which is the 8-bit way to write the number 5 in binary?
A. 00000101 ✓
B. 10100000
Leading zeros go on the LEFT. 101 padded to 8 bits is 00000101. Putting zeros on the right would change the value.
2. Adding leading zeros to a binary number changes its value.
A. True
B. False ✓
Leading zeros are like writing 007 instead of 7. They fill space but the value stays the same.
3. Do 101 and 00000101 mean the same number?
A. No, 00000101 is bigger
B. Yes, both are 5 ✓
The extra zeros on the left add 0 at each higher place value, so both still equal 4 + 1 = 5.
4. Why do computers pad binary codes to a fixed length like 8 bits?
A. So every code is the same size and is easy to separate and read ✓
B. So the number becomes bigger
Fixed-length codes make it easy to know where one value ends and the next begins. Padding never makes the number bigger.
5. Where do you add the extra 0s to pad 11 to 8 bits?
A. On the left: 00000011 ✓
B. On the right: 11000000
Padding goes at the left, in front of the number. 11000000 would be 192, not 3.

Match the Pairs

00000101 → The number 5 written as an 8-bit binary number, with five leading zeros added to fill all 8 bits
0011 → The number 3 written in 4 bits, with two leading zeros padding the binary number 11
Leading zeros do not change the value of a binary number, so these two numbers are both 5 → 101 = 00000101
Fixed-length codes make every character the same size, so 'A' (65) is stored in 8 bits with a leading zero → 01000001
5 in 8 bits = 10100000 → The zeros were added on the right instead of the left. That changes the value to 160. Padding must go on the left: 00000101.
6 in 4 bits = 110000 → This has 6 bits, not 4, and the zeros are on the right. Padding 110 to 4 bits should give 0110.

Key Term

leading zeros
Extra 0s added at the left of a binary number to fill a fixed number of bits. They do not change its value: 101 and 00000101 both mean 5.

Fill in the Blanks

1. 101 padded to 8 bits = 00000101
Hint: Type the zeros added on the left so 101 fills 8 bits
2. 00000101 and 101 both have the value 5
Hint: Type the decimal number that both binary numbers represent
3. Pad 11 to 4 bits: 0011
Hint: Type the leading zeros needed to make 11 fill 4 bits
4. Leading zeros do not change the value
Hint: Type the word for what stays the same when zeros are added on the left
5. Each character is padded to 8 bits. 3 characters = 3 x 8 = 24 bits
Hint: Type the total number of bits for three fixed-length characters

Spot the Error

Question 1
A n = 5
B bits = format(n, "8b")
C print(bits)
Line B — Without the 0 in the format code, the number is padded with spaces instead of zeros. It should be "08b" so 5 becomes 00000101.
Question 2
A n = 5
B bits = bin(n)[2:].zfill(3)
C print(bits)
Line B — Padding to a width of 3 leaves 101 unchanged. An 8-bit code needs zfill(8) to give 00000101.
Question 3
A width = 3
B code = "101"
C padded = code.zfill(width)
D print(padded)
Line A — The fixed length is 8 bits, so width must be 8. A width of 3 adds no leading zeros because 101 is already 3 bits long.
Question 4
A code = 101
B zeros = "0" * (8 - len(code))
C print(zeros + code)
Line A — len() only works on a string, and 101 without quotes is a number. It should be code = "101" so the bits can be counted and padded.
Question 5
A bits = "101"
B size = 8
C zeros = size - len(bits)
D padded = bits + "0" * zeros
E print(padded)
Line D — The zeros must go on the left of the number as leading zeros. Putting them on the right gives 10100000, which is 160, not 5.

Student with a class code? Join your class →