Text, images and sound all become integers, then binary

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

Text, images and sound all become integers, then binary

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. How does a computer store the letter 'A'?
A As a tiny picture of the letter A saved in memory
B As a character code (65 in ASCII), which is stored as binary
2. What numbers describe the colour of one pixel in an image?
A The letters of the colour name, like R-E-D
B Red, green and blue values from 0 to 255
3. What is a sound sample?
A A number measuring the volume of the sound at one moment
B A short clip of the song saved as text
4. Which statement is true about the binary used for text, images and sound?
A All three use the same 0s and 1s
B Each type of data needs its own special kind of binary
5. What is the correct order for storing an image pixel?
A Colour, then RGB numbers, then binary
B Colour, then binary, then RGB numbers

Match the Pairs

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

Left columnRight column
1CODE("A") returns 65 AAll data is turned into whole numbers and stored as binary. Images use RGB pixel numbers, sounds use sample numbers, and text uses character codes.
2rgb(255, 0, 0) Bsamples = [0, 12, 40, 12, 0]
3A sound is measured many times a second, and each volume measurement (sample) is a whole number CThe letter A is stored as the character code 65, which is then saved as binary
4Every kind of data ends up as the same thing: a whole number written in binary DOne pixel is stored as three numbers (red, green, blue), here pure red, each saved as binary
5"Hi" is stored as the letters H and i inside the computer EComputers do not store letters directly. Each letter is first turned into a number code (H = 72, i = 105) and then stored as binary.
6Photos are stored as pictures, while sounds and text use a different kind of storage F65 = 01000001

Definitions

encoding

Fill in the Blanks

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

1.
letter ← "A" code ← __ binary ← 01000001
2.
colour ← "red" pixel ← (255, _, 0) binary ← 11111111 00000000 00000000
3.
sound ← [12, 40, 90, 40, 12] FOR EACH ______ IN sound binary ← toBinary(sample)
4.
code ← 65 bits ← toBinary(code, _) DISPLAY bits
5.
pixel ← (255, 128, 0) valuesPerPixel ← _ bitsPerPixel ← valuesPerPixel * 8

Spot the Error

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

Question 1
A letter = 'A'
B code = ord(letter)
C bits = format(letter, '08b')
D print(bits)
Question 2
A red = 255
B green = 0
C blue = 256
D pixel = (red, green, blue)
Question 3
A samples = [0, 5, 9, 5]
B for s in samples:
C bits = format(s, '08b')
D print(s)
Question 4
A word = 'Hi'
B codes = [chr(c) for c in word]
C print(codes)
Question 5
A rate = 44100
B sample ← 'loud'
C store(toBinary(sample))

Answer Key

Text, images and sound all become integers, then binary
Section A: Quick Questions
Q1
B — As a character code (65 in ASCII), which is stored as binary
Q2
B — Red, green and blue values from 0 to 255
Q3
A — A number measuring the volume of the sound at one moment
Q4
A — All three use the same 0s and 1s
Q5
A — Colour, then RGB numbers, then binary
Section B: Match the Pairs
Q1
CODE("A") returns 65 → The letter A is stored as the character code 65, which is then saved as binary
Q2
rgb(255, 0, 0) → One pixel is stored as three numbers (red, green, blue), here pure red, each saved as binary
Q3
A sound is measured many times a second, and each volume measurement (sample) is a whole number → samples = [0, 12, 40, 12, 0]
Q4
Every kind of data ends up as the same thing: a whole number written in binary → 65 = 01000001
Q5
"Hi" is stored as the letters H and i inside the computer → Computers do not store letters directly. Each letter is first turned into a number code (H = 72, i = 105) and then stored as binary.
Q6
Photos are stored as pictures, while sounds and text use a different kind of storage → All data is turned into whole numbers and stored as binary. Images use RGB pixel numbers, sounds use sample numbers, and text uses character codes.
Section C: Definitions
Q1
encoding — Encoding turns text, images and sound into whole numbers (character codes, RGB pixel values, sound samples), then stores each number as binary 0s and 1s.
Section D: Fill in the Blanks
Q1
letter ← "A" code ← 65 binary ← 01000001
Q2
colour ← "red" pixel ← (255, 0, 0) binary ← 11111111 00000000 00000000
Q3
sound ← [12, 40, 90, 40, 12] FOR EACH sample IN sound binary ← toBinary(sample)
Q4
code ← 65 bits ← toBinary(code, 8) DISPLAY bits
Q5
pixel ← (255, 128, 0) valuesPerPixel ← 3 bitsPerPixel ← valuesPerPixel * 8
Section E: Spot the Error
Q1
C — Binary conversion needs the number code, not the letter. It should be format(code, '08b') so the ASCII code 65 becomes 01000001.
Q2
C — RGB values only go from 0 to 255 because each one fits in one byte (8 bits). 256 is too big, so it should be a value like 0.
Q3
D — This prints the decimal sample number, not its binary. The program should print(bits) so each sample is shown as binary 0s and 1s.
Q4
B — chr() turns a number into a character, which is the wrong way round. To get the ASCII code of each character use ord(c).
Q5
B — A sound sample is a whole number measuring the volume, so it can be turned into binary. It should be sample = 200, not text.