The worksheetDownload the PDF
Answers

F8.1 Bits, bytes and units

Data representation · GCSE · OCR J277 1.2.3, AQA 8525 3.3.3, Edexcel 1CP2 2.1.1 · about 12 min

BugBotLab

What this lesson is about

Why computers use binary, and the units from bits to petabytes.

Questions 6 marks in all

  1. [1 mark]Why do computers store data in binary?

    1. ATheir circuits are made of switches that are either on or off
    2. BBinary uses less electricity than denary
    3. CBinary numbers are shorter
    4. DIt was the first number system invented
    Answer: A. Transistors reliably hold two states, so two symbols are used.
  2. [1 mark]Put the units in order from smallest to largest.

    Number the lines 1 to 7 to put them in the right order.

    1. nibble
    2. terabyte
    3. megabyte
    4. gigabyte
    5. kilobyte
    6. bit
    7. byte
    Answer:
    bit
    nibble
    byte
    kilobyte
    megabyte
    gigabyte
    terabyte

    Each step up the list is bigger.

  3. [1 mark]How many bits are in a byte?

    Answer: 8. A byte is 8 bits; a nibble is 4.
  4. [1 mark]How many different patterns can 5 bits make?

    Answer: 32. 2 to the power 5 is 32.
  5. [1 mark]What does this program print?

    frame_bytes = 320 * 240 * 3
    print(frame_bytes, frame_bytes / 1000)
    Answer:
    230400 230.4

    320 × 240 × 3 bytes is 230,400 bytes, or 230.4 kB.

  6. [1 mark]How many bytes is a kibibyte?

    1. A1,024
    2. B1,000
    3. C8
    4. D1,000,000
    Answer: A. Binary prefixes step up by 1,024; the decimal kilobyte is 1,000 bytes.

The task: frame sizes

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.

A solution

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.