Data representation · GCSE · OCR J277 1.2.3, AQA 8525 3.3.3, Edexcel 1CP2 2.1.1 · about 12 min
Why computers use binary, and the units from bits to petabytes.
[1 mark]Why do computers store data in binary?
[1 mark]Put the units in order from smallest to largest.
Number the lines 1 to 7 to put them in the right order.
nibbleterabytemegabytegigabytekilobytebitbytebit nibble byte kilobyte megabyte gigabyte terabyte
Each step up the list is bigger.
[1 mark]How many bits are in a byte?
[1 mark]How many different patterns can 5 bits make?
[1 mark]What does this program print?
frame_bytes = 320 * 240 * 3 print(frame_bytes, frame_bytes / 1000)
230400 230.4
320 × 240 × 3 bytes is 230,400 bytes, or 230.4 kB.
[1 mark]How many bytes is a kibibyte?
The robot's camera can also capture a small 64 by 48 frame with 3 bytes per pixel. Work out and print three lines: bits: <n>, bytes: <n> and kB: <n> (kilobytes of 1,000 bytes, as a decimal). Store the width, height and bytes per pixel in variables and calculate each line; do not type the answers.
# the two lines every program starts with: the commands, then the robot from bugbot import * connect() width = 64
The hint students can ask for: Multiply the pixels by the bytes each one takes. Bits are eight times the bytes, and the larger unit divides by a thousand.
from bugbot import *
connect()
width = 64
height = 48
bytes_per_pixel = 3
bytes = width * height * bytes_per_pixel
print('bits:', bytes * 8)
print('bytes:', bytes)
print('kB:', bytes / 1000)
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.