Character set

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

Character set

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What is a character set?
A An agreed list of characters, each with its own unique binary code
B A list of characters that all share the same binary code
2. Why must two devices use the same character set to share a text message?
A So the message uses fewer bits when it is sent
B So the codes sent are read as the same characters
3. Which of these can be stored in a character set?
A Only the letters A to Z
B Letters, digits, punctuation and symbols
4. The digit 5 typed as text is stored as...
A A character with its own code in the set
B No code, because it is a number
5. A character set needs to add thousands more characters. What happens to the length of the codes?
A Longer codes are needed, so more bits per character
B The codes can stay the same length

Match the Pairs

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

Left columnRight column
1character set A'a' = 01100001, '7' = 00110111, '!' = 00100001, '#' = 00100011
201000001 = 'A' BOne entry in a character set: a unique binary code that every device reads as the same character
3A bigger character set needs longer codes, because more bits are needed to give each character a unique code C7 bits = 128 codes, 8 bits = 256 codes
4A character set covers letters, digits, punctuation and symbols, and each one gets its own code DThe agreed list of characters a system can use, each with its own unique binary code
5Phone A uses one character set and Phone B uses a different one. A text sent as 01000001 is always shown as 'A' on both phones. E8 bits give only 256 different codes, which is fewer than 300. The set needs longer codes, such as 9 bits or more.
6A character set with 300 characters can give every character a unique code using only 8 bits. FDevices must share the same character set. If the sets differ, the same binary code can be shown as a different character, so the message is garbled.

Definitions

character set

Fill in the Blanks

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

1.
code = ___("A") print(code)
2.
print(___(65))
3.
print(___(ord("A")))
4.
bits = 8 characters = 2 ** ____ print(characters)
5.
print(chr(65) __ "A")

Spot the Error

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

Question 1
A bits = 7
B size = 2 * bits
C print(size)
Question 2
A letter = 'A'
B code = chr(letter)
C print(code)
Question 3
A code = ord('A')
B next_code = code + 1
C print(ord(next_code))
Question 4
A bits = '8'
B chars = 2 ** bits
C print(chars)
Question 5
A char = A
B code = ord(char)
C print(code)

Answer Key

Character set
Section A: Quick Questions
Q1
A — An agreed list of characters, each with its own unique binary code
Q2
B — So the codes sent are read as the same characters
Q3
B — Letters, digits, punctuation and symbols
Q4
A — A character with its own code in the set
Q5
A — Longer codes are needed, so more bits per character
Section B: Match the Pairs
Q1
character set → The agreed list of characters a system can use, each with its own unique binary code
Q2
01000001 = 'A' → One entry in a character set: a unique binary code that every device reads as the same character
Q3
A bigger character set needs longer codes, because more bits are needed to give each character a unique code → 7 bits = 128 codes, 8 bits = 256 codes
Q4
A character set covers letters, digits, punctuation and symbols, and each one gets its own code → 'a' = 01100001, '7' = 00110111, '!' = 00100001, '#' = 00100011
Q5
Phone A uses one character set and Phone B uses a different one. A text sent as 01000001 is always shown as 'A' on both phones. → Devices must share the same character set. If the sets differ, the same binary code can be shown as a different character, so the message is garbled.
Q6
A character set with 300 characters can give every character a unique code using only 8 bits. → 8 bits give only 256 different codes, which is fewer than 300. The set needs longer codes, such as 9 bits or more.
Section C: Definitions
Q1
character set — The agreed list of characters a system can use, with a unique binary code for each one, so every device reads the same code as the same character.
Section D: Fill in the Blanks
Q1
code = ord("A") print(code)
Q2
print(chr(65))
Q3
print(bin(ord("A")))
Q4
bits = 8 characters = 2 ** bits print(characters)
Q5
print(chr(65) == "A")
Section E: Spot the Error
Q1
B — The number of codes n bits can store is 2 to the power n, so the line must be size = 2 ** bits. With 7 bits that gives 128 codes, but 2 * bits would give only 14.
Q2
B — ord() turns a character into its number code. chr() does the opposite and turns a number into a character. The line should be code = ord(letter).
Q3
C — next_code is already a number, so ord() cannot be used on it. To show the character that has that code, use chr(next_code), which prints B.
Q4
A — The number of bits must be a number, not a string. With bits = '8', the calculation 2 ** bits causes an error. It should be bits = 8.
Q5
A — A character must be written inside quotes. Without quotes Python treats A as a variable name that does not exist. It should be char = 'A'.