Odd parity

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Odd parity

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. With odd parity, the total number of 1s in the byte (including the parity bit) must be...
A Odd
B Even
2. Data bits 1100 0011 (four 1s) use odd parity. What should the parity bit be?
A 1
B 0
3. Data bits 1011 0001 (four 1s) use odd parity. What should the parity bit be?
A 0
B 1
4. Data bits 1110 0000 (three 1s) use odd parity. What should the parity bit be?
A 1
B 0
5. Which statement about odd parity is correct?
A If the data has an even number of 1s, the parity bit is 1
B If the data has an even number of 1s, the parity bit is 0

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
11011001 -> parity bit 1 AOdd parity: the data already has three 1s (odd), so the parity bit stays 0
21101100 -> parity bit 0 BOdd parity: the data has four 1s (even), so the parity bit is 1 to make five 1s in total
3With odd parity, data with an even number of 1s needs the parity bit set to 1 C0110 0000 -> 1 0110 0000
4Switching from even parity to odd parity flips the parity bit for the same data DThe data 1110 0000 already has three 1s, which is odd, so the parity bit should be 0. Adding 1 makes the total four, which is even.
5Odd parity: 1110 0000 -> parity bit 1 (total four 1s) EThe data 1001 0000 has two 1s, which is even, so the parity bit should be 1. A bit of 0 leaves an even total, which breaks the odd parity rule.
6Odd parity: 1001 0000 -> parity bit 0 (total two 1s) FData 0100 0001: even parity bit 0, odd parity bit 1

Definitions

odd parity

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
IF ones MOD 2 = 0 THEN parity ← _
2.
IF ones MOD 2 = 1 THEN parity ← _ ENDIF
3.
IF ones ___ 2 = 0 THEN parity ← 1
4.
Data: 11000000 (two 1s) Even parity bit: 0 Odd parity bit: _
5.
Data: 1110000 has three 1s (odd) Odd parity bit: 0 Sent byte: _1110000

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A data = "1011001"
B ones = len(data)
C parity = 1 - ones % 2
D print(str(parity) + data)
Question 2
A ones = 4
B if ones % 2 == 1:
C parity = 1
D else:
E parity = 0
Question 3
A data = "1100000"
B ones = data.count("1")
C parity = 1 - ones % 2
D total = ones - parity
E print(total % 2 == 1)
Question 4
A byte = "10110010"
B ones = byte.count("1")
C if ones % 2 == 0:
D print("Odd parity OK")
E else:
F print("Parity error")
Question 5
A data = "0010110"
B ones = data.count("1")
C parity = 1 if ones % 2 else 0
D print(data + str(parity))

Answer Key

Odd parity
Section A: Quick Questions
Q1
A — Odd
Q2
A — 1
Q3
B — 1
Q4
B — 0
Q5
A — If the data has an even number of 1s, the parity bit is 1
Section B: Match the Pairs
Q1
1011001 -> parity bit 1 → Odd parity: the data has four 1s (even), so the parity bit is 1 to make five 1s in total
Q2
1101100 -> parity bit 0 → Odd parity: the data already has three 1s (odd), so the parity bit stays 0
Q3
With odd parity, data with an even number of 1s needs the parity bit set to 1 → 0110 0000 -> 1 0110 0000
Q4
Switching from even parity to odd parity flips the parity bit for the same data → Data 0100 0001: even parity bit 0, odd parity bit 1
Q5
Odd parity: 1110 0000 -> parity bit 1 (total four 1s) → The data 1110 0000 already has three 1s, which is odd, so the parity bit should be 0. Adding 1 makes the total four, which is even.
Q6
Odd parity: 1001 0000 -> parity bit 0 (total two 1s) → The data 1001 0000 has two 1s, which is even, so the parity bit should be 1. A bit of 0 leaves an even total, which breaks the odd parity rule.
Section C: Definitions
Q1
odd parity — A rule where the parity bit is set so the total number of 1s in the byte, including the parity bit, is odd. Even number of 1s in the data gives bit 1; odd number gives bit 0.
Section D: Fill in the Blanks
Q1
IF ones MOD 2 = 0 THEN parity ← 1
Q2
IF ones MOD 2 = 1 THEN parity ← 0 ENDIF
Q3
IF ones MOD 2 = 0 THEN parity ← 1
Q4
Data: 11000000 (two 1s) Even parity bit: 0 Odd parity bit: 1
Q5
Data: 1110000 has three 1s (odd) Odd parity bit: 0 Sent byte: 01110000
Section E: Spot the Error
Q1
B — len(data) counts every bit, not just the 1s. Odd parity depends on the number of 1s, so it should be data.count("1").
Q2
B — With odd parity, an even number of 1s needs parity bit 1. The test must be ones % 2 == 0. Testing for == 1 swaps the two cases, which is the wrong way round.
Q3
D — The total number of 1s includes the parity bit, so the parity bit must be added: total = ones + parity. Subtracting it gives the wrong total.
Q4
C — A byte passes an odd parity check when its total number of 1s is odd, so the test should be ones % 2 == 1. Testing for == 0 is the even parity rule.
Q5
C — The data has three 1s, which is already odd, so the parity bit must be 0. This line gives 1 when the count is odd, which is the even parity rule. It should be 0 if ones % 2 else 1.