ViewWiki

Answer key · Unit 1

Bits and data.

Each lesson’s practice questions, their correct answers and the mistakes they spot. Answers read off the Scene use the same setting the learner sees.

Lesson 1 of 4 · About 20 minutes

Bits on switches

A switch that is a number: what a bit is, how many patterns two bits make, place value in base 2, and why 10 in base 2 is two.

Open the lesson

The 5 steps and their answers
  1. Step 1 of 5

    Open this step

    One bit

    Practice · Calculate

    Question

    The board has two switches, A and B, and each can be set to 0 or 1. How many different patterns can the two switches make?

    Correct answer

    4 ± 0.01

    Setup, choices and feedback

    The Scene at this step

    Number
    0fixed
    Three gates / Half adder
    Three gateshidden
    Accepted within
    ± 0.01
    A fixed value in the question

    Wrong answers it recognises

    Feedback for a right answer

    Four: 00, 01, 10 and 11. Each of A’s two settings goes with each of B’s two, 2×2=42 \times 2 = 4⁠, and they are the numbers 00⁠ to 33⁠.

    Hint

    List them: A at 0 with each setting of B, then A at 1 with each setting of B.

    Worked solution

    1. With A at 0, B has two settings: 00 and 01.
    2. With A at 1, two more: 10 and 11.
    3. In all, 2×2=42 \times 2 = 4⁠ patterns.

    If you answered 33⁠, you counted up to the largest number and forgot 00⁠. If you answered 22⁠, you counted one setting per switch instead of combining them.

  2. Step 2 of 5

    Open this step

    Place value

    Practice · Predict, then look

    Question

    Number is at 0, and both switches are down. A is the 2s place and B the 1s place. How will the switches stand when the number is 22⁠?

    Correct answer

    • Correct A = 1, B = 0

    Setup, choices and feedback

    The Scene at this step

    Number
    0fixed
    Three gates / Half adder
    Three gateshidden

    Choices

    • Correct A = 1, B = 0

    • Wrong A = 0, B = 1

      Misconception: Gives the rightmost bit the largest place value, reading the number back to front.

      Feedback from the catalogue

      As in decimal numbers, the rightmost digit is the ones, and the place values grow to its left. In base 2 the rightmost bit is worth 11⁠, the next 22⁠, then 44⁠, 88⁠ and so on. On the board’s switches A is the 2s place and B the 1s place, so the number 22⁠ is A = 1, B = 0. Read backwards, 11012=131101_2 = 13⁠ turns into 10112=111011_2 = 11⁠.

    • Wrong A = 1, B = 1, since two needs two switches

      Misconception: Takes the value of a binary number to be the number of 1s in it.

      Feedback from the catalogue

      Each 1 adds its place value, not 11⁠. 101121011_2⁠ has three 1s, but they stand in the places of 88⁠, 22⁠ and 11⁠, so the value is 8+2+1=118 + 2 + 1 = 11⁠. And 10210_2⁠, with a single 1, is 22⁠, because that 1 stands in the 2s place.

    Once the prediction is locked in, the Scene changes

    Number
    2fixed

    A prediction is never marked as a failure: the learner sees the outcome and the explanation either way.

    Feedback for a right answer

    2=1×2+0×12 = 1 \times 2 + 0 \times 1⁠, so A, the 2s place, goes up and B stays down: 10210_2⁠. It reads “one zero”, and in base 2 it is two.

    Worked solution

    1. The place values: A is worth 22⁠ and B is worth 11⁠.
    2. To make 22⁠ you need the 2 and not the 1: 2=1×2+0×12 = 1 \times 2 + 0 \times 1⁠.
    3. So A = 1, B = 0, that is 10210_2⁠.

    A = 0, B = 1 is 11⁠: what you get by reading the bits from the end. A = 1, B = 1 is 2+1=32 + 1 = 3⁠.

  3. Step 3 of 5

    Open this step

    One one

    Practice · Reach the target

    Question

    Move Number until both switches are up, the bits 11, and press Check. Which number is it?

    Goal

    • 1 ± 0.01

      At the start of the step: 0

    • 1 ± 0.01

      At the start of the step: 0

    Setup, choices and feedback

    The Scene at this step

    Number
    0
    Three gates / Half adder
    Three gateshidden
    Read from the Scene at
    Logic: input bit A, the 2s place of inputs/nodes/board/outputs/bitA
    Read from the Scene at
    Logic: input bit B, the 1s place of inputs/nodes/board/outputs/bitB

    One setting that reaches it

    Number
    3

    Feedback for a right answer

    112=2+1=311_2 = 2 + 1 = 3⁠: the largest number two bits can hold. To reach 44⁠ you need a third bit, in the 4s place.

    Feedback for a wrong answer

    Not yet. While either switch is down, raise Number.

    Hint

    A is worth 22⁠ and B is worth 11⁠. What do they add up to when both are on?

    Worked solution

    1. With both switches up, A adds 22⁠ and B adds 11⁠.
    2. 112=1×2+1×1=311_2 = 1 \times 2 + 1 \times 1 = 3⁠.
    3. Move Number to 3.

    It is not eleven: 11 in base 2 is three.

  4. Step 4 of 5

    Open this step

    More bits

    Practice · Calculate

    Question

    Add two more switches on the left, in the 4s and 8s places. The four switches show 1011. Which decimal number is that?

    Correct answer

    11 ± 0.01

    Setup, choices and feedback

    The Scene at this step

    Number
    3
    Three gates / Half adder
    Three gateshidden
    Accepted within
    ± 0.01
    A fixed value in the question

    Wrong answers it recognises

    • 1011 ± 0.01

      Misconception: Reads a binary numeral as if it were decimal: takes 10 in binary to be ten.

      Feedback from the catalogue

      The digits 0 and 1 are the same digits, but the place values differ. In base ten each place is worth 10 times the one to its right; in base 2 only twice: from right to left 1,2,4,8,16,…1, 2, 4, 8, 16, \ldots⁠ So 10210_2⁠ is 1×2+0=21 \times 2 + 0 = 2⁠, not ten, and 101121011_2⁠ is 8+2+1=118 + 2 + 1 = 11⁠. When in doubt, write the base as a subscript.

    • 13 ± 0.01

      Misconception: Gives the rightmost bit the largest place value, reading the number back to front.

      Feedback from the catalogue

      As in decimal numbers, the rightmost digit is the ones, and the place values grow to its left. In base 2 the rightmost bit is worth 11⁠, the next 22⁠, then 44⁠, 88⁠ and so on. On the board’s switches A is the 2s place and B the 1s place, so the number 22⁠ is A = 1, B = 0. Read backwards, 11012=131101_2 = 13⁠ turns into 10112=111011_2 = 11⁠.

    • 3 ± 0.01

      Misconception: Takes the value of a binary number to be the number of 1s in it.

      Feedback from the catalogue

      Each 1 adds its place value, not 11⁠. 101121011_2⁠ has three 1s, but they stand in the places of 88⁠, 22⁠ and 11⁠, so the value is 8+2+1=118 + 2 + 1 = 11⁠. And 10210_2⁠, with a single 1, is 22⁠, because that 1 stands in the 2s place.

    Feedback for a right answer

    10112=8+0+2+1=111011_2 = 8 + 0 + 2 + 1 = 11⁠.

    Hint

    The place values from left to right: 8,4,2,18, 4, 2, 1⁠. Add the ones with a 1 above them.

    Worked solution

    1. The place values of four bits, from left to right: 8,4,2,18, 4, 2, 1⁠.
    2. The bits 1,0,1,11, 0, 1, 1⁠ take the 88⁠, not the 44⁠, and the 22⁠ and the 11⁠.
    3. 8+2+1=118 + 2 + 1 = 11⁠.

    If you got 1313⁠, you read the bits from the end. If you got 33⁠, you counted the 1s instead of adding their place values.

  5. Step 5 of 5

    Open this step

    The largest number

    Practice · Calculate

    Question

    What is the largest number four bits can hold?

    Correct answer

    15 ± 0.01

    Setup, choices and feedback

    The Scene at this step

    Number
    3
    Three gates / Half adder
    Three gateshidden
    Accepted within
    ± 0.01
    A fixed value in the question

    Wrong answers it recognises

    Feedback for a right answer

    11112=8+4+2+1=151111_2 = 8 + 4 + 2 + 1 = 15⁠. Four bits give 24=162^4 = 16⁠ values, 00⁠ to 1515⁠, and the largest is one less than 1616⁠, the worth of the next bit.

    Hint

    Turn all four bits on.

    Worked solution

    1. The largest is with every bit on: 111121111_2⁠.
    2. 8+4+2+1=158 + 4 + 2 + 1 = 15⁠.
    3. Check: 24=162^4 = 16⁠ values, from 00⁠ to 1515⁠.

    If you answered 1616⁠, you counted how many values there are, not the largest of them.

Lesson 2 of 4 · About 30 minutes

Counting in base 2

How many values fit in so many bits, why each bit doubles them, the byte and 255, and converting between base 2 and base ten both ways.

Open the lesson

The 7 steps and their answers
  1. Step 1 of 7

    Open this step

    How many values in how many bits

    Practice · Predict, then look

    Question

    Each of a pixel’s three colour channels, red, green and blue, is stored here in 3 bits. How many different levels can one channel take?

    Correct answer

    8 ± 0.01

    A number prediction counts as right within ± 0.01

    Setup, choices and feedback

    The Scene at this step

    Pixels across
    64 px
    Bits per channel
    3 bitfixed
    Picture / Red, green, blue
    Picturefixed

    Once the prediction is locked in, the Scene changes

    Picture / Red, green, blue
    Red, green, bluefixed

    The Scene then shows: 8 · Levels each channel can take, 2^bits/nodes/picture/outputs/levels

    A prediction is never marked as a failure: the learner sees the outcome and the explanation either way.

    Feedback for a right answer

    23=82^3 = 8⁠ levels, from 0002000_2⁠ to 1112111_2⁠, that is 00⁠ to 77⁠. Look inside shows the red, green and blue columns beside a ruler of eight levels.

    Worked solution

    1. Each bit doubles the number of patterns: 2×2×22 \times 2 \times 2⁠.
    2. 23=82^3 = 8⁠.
    3. The levels are 00⁠ to 77⁠.

    The board also shows 512 colours: that is 8×8×88 \times 8 \times 8⁠, the combinations of the three channels.

  2. Step 2 of 7

    Open this step

    Each bit doubles

    Practice · Predict, then look

    Question

    At four bits per channel there are 16 levels. How many will there be when the bits double to 8?

    Correct answer

    • Correct 256

    Setup, choices and feedback

    The Scene at this step

    Pixels across
    64 px
    Bits per channel
    4 bitfixed
    Picture / Red, green, blue
    Picturefixed

    Choices

    • Wrong 32, twice as many

      Misconception: Thinks each extra bit adds a fixed number of values instead of doubling them (2 bits give 2, 8 bits give twice what 4 give).

      Feedback from the catalogue

      Each extra bit doubles the number of values: every pattern of the earlier bits appears once with a 0 in the new bit and once with a 1. So nn⁠ bits give 2×2×⋯×2=2n2 \times 2 \times \cdots \times 2 = 2^n⁠ values: 4 bits give 16, and 8 bits give not 32 but 16×16=25616 \times 16 = 256⁠.

    • Wrong 64

      Feedback

      64=2664 = 2^6⁠: that is what six bits give. Each of the four extra bits doubles.

    • Correct 256

    Once the prediction is locked in, the Scene changes

    Bits per channel
    8 bitfixed
    Picture / Red, green, blue
    Red, green, bluefixed

    The Scene then shows: 256 · Levels each channel can take, 2^bits/nodes/picture/outputs/levels

    A prediction is never marked as a failure: the learner sees the outcome and the explanation either way.

    Feedback for a right answer

    28=2562^8 = 256⁠. The four extra bits double it four times: 16×2×2×2×2=16×16=25616 \times 2 \times 2 \times 2 \times 2 = 16 \times 16 = 256⁠. The bands in the sky disappear.

    Worked solution

    1. 4 bits: 24=162^4 = 16⁠ levels.
    2. Each extra bit doubles: four more bits are ×24=×16\times 2^4 = \times 16⁠.
    3. 16×16=256=2816 \times 16 = 256 = 2^8⁠.

    Doubling the bits does not double the levels; it squares them.

  3. Step 3 of 7

    Open this step

    By the number of levels

    Practice · Reach the target

    Question

    Change Bits per channel so that each channel has exactly 64 levels, and press Check.

    Goal

    • 64 ± 0.01

      At the start of the step: 8

    Setup, choices and feedback

    The Scene at this step

    Pixels across
    64 px
    Bits per channel
    3 bit
    Picture / Red, green, blue
    Red, green, blue
    Read from the Scene at
    Levels each channel can take, 2^bits/nodes/picture/outputs/levels

    One setting that reaches it

    Pixels across
    16 px
    Bits per channel
    6 bit

    Feedback for a right answer

    Six bits: 26=642^6 = 64⁠, levels 00⁠ to 6363⁠.

    Feedback for a wrong answer

    Not yet. Each bit doubles the levels: count the doublings from 11⁠ to 6464⁠.

    Hint

    How many times must you multiply 2 by itself to reach 6464⁠?

    Worked solution

    1. 2,4,8,16,32,642, 4, 8, 16, 32, 64⁠: six doublings.
    2. So 64=2664 = 2^6⁠, that is 6 bits.
    3. Set Bits per channel to 6.
  4. Step 4 of 7

    Open this step

    A byte

    Practice · Calculate

    Question

    In true colour each channel is a byte, 8 bits. What is the largest value such a channel stores, the brightest red?

    Correct answer

    255 ± 0.01

    Setup, choices and feedback

    The Scene at this step

    Pixels across
    64 px
    Bits per channel
    8 bitfixed
    Picture / Red, green, blue
    Red, green, blue
    Accepted within
    ± 0.01
    Computed from the Scene at this step’s setting
    The largest value a channel stores, 2^bits − 1 (255 for 8 bits)/nodes/picture/outputs/maxLevel

    Wrong answers it recognises

    Feedback for a right answer

    255=111111112255 = 11111111_2⁠. A byte has 28=2562^8 = 256⁠ values, 00⁠ to 255255⁠, which is why colour codes go up to 255 and not 256.

    Hint

    How many values are there, and does the count start at 00⁠ or at 11⁠?

    Worked solution

    1. 8 bits give 28=2562^8 = 256⁠ values.
    2. They start at 00⁠, so the largest is 256−1=255256 - 1 = 255⁠.
    3. Check: 111111112=128+64+32+16+8+4+2+1=25511111111_2 = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255⁠.
  5. Step 5 of 7

    Open this step

    Reading a byte

    Practice · Calculate

    Question

    A pixel’s red channel is stored as the byte 1100 100021100\,1000_2⁠. What is it in base ten?

    Correct answer

    200 ± 0.01

    Setup, choices and feedback

    The Scene at this step

    Pixels across
    64 px
    Bits per channel
    8 bit
    Picture / Red, green, blue
    Red, green, blue
    Accepted within
    ± 0.01
    A fixed value in the question

    Wrong answers it recognises

    • 19 ± 0.01

      Misconception: Gives the rightmost bit the largest place value, reading the number back to front.

      Feedback from the catalogue

      As in decimal numbers, the rightmost digit is the ones, and the place values grow to its left. In base 2 the rightmost bit is worth 11⁠, the next 22⁠, then 44⁠, 88⁠ and so on. On the board’s switches A is the 2s place and B the 1s place, so the number 22⁠ is A = 1, B = 0. Read backwards, 11012=131101_2 = 13⁠ turns into 10112=111011_2 = 11⁠.

    • 3 ± 0.01

      Misconception: Takes the value of a binary number to be the number of 1s in it.

      Feedback from the catalogue

      Each 1 adds its place value, not 11⁠. 101121011_2⁠ has three 1s, but they stand in the places of 88⁠, 22⁠ and 11⁠, so the value is 8+2+1=118 + 2 + 1 = 11⁠. And 10210_2⁠, with a single 1, is 22⁠, because that 1 stands in the 2s place.

    • 11000000 ± 0.01

      Misconception: Reads a binary numeral as if it were decimal: takes 10 in binary to be ten.

      Feedback from the catalogue

      The digits 0 and 1 are the same digits, but the place values differ. In base ten each place is worth 10 times the one to its right; in base 2 only twice: from right to left 1,2,4,8,16,…1, 2, 4, 8, 16, \ldots⁠ So 10210_2⁠ is 1×2+0=21 \times 2 + 0 = 2⁠, not ten, and 101121011_2⁠ is 8+2+1=118 + 2 + 1 = 11⁠. When in doubt, write the base as a subscript.

    Feedback for a right answer

    128+64+8=200128 + 64 + 8 = 200⁠: a strong red, near the brightest, 255.

    Hint

    The place values of a byte, from left to right: 128,64,32,16,8,4,2,1128, 64, 32, 16, 8, 4, 2, 1⁠.

    Worked solution

    1. Write the place values over the bits: 128,64,32,16,8,4,2,1128, 64, 32, 16, 8, 4, 2, 1⁠ over 1,1,0,0,1,0,0,01, 1, 0, 0, 1, 0, 0, 0⁠.
    2. The 1s stand under 128128⁠, 6464⁠ and 88⁠.
    3. 128+64+8=200128 + 64 + 8 = 200⁠.

    If you got 1919⁠, you read the byte from the end (0001 001120001\,0011_2⁠).

  6. Step 6 of 7

    Open this step

    Writing a byte

    Practice · Choose

    Question

    Which byte stores the number 100100⁠?

    Correct answer

    • Correct 0110 010020110\,0100_2⁠

    Setup, choices and feedback

    The Scene at this step

    Pixels across
    64 px
    Bits per channel
    8 bit
    Picture / Red, green, blue
    Red, green, blue

    Choices

    Shown in a random order.

    • Correct 0110 010020110\,0100_2⁠

    • Wrong 0010 011020010\,0110_2⁠

      Misconception: Gives the rightmost bit the largest place value, reading the number back to front.

      Feedback from the catalogue

      As in decimal numbers, the rightmost digit is the ones, and the place values grow to its left. In base 2 the rightmost bit is worth 11⁠, the next 22⁠, then 44⁠, 88⁠ and so on. On the board’s switches A is the 2s place and B the 1s place, so the number 22⁠ is A = 1, B = 0. Read backwards, 11012=131101_2 = 13⁠ turns into 10112=111011_2 = 11⁠.

    • Wrong 0000 010020000\,0100_2⁠, the digits 1, 0, 0 at the end

      Misconception: Reads a binary numeral as if it were decimal: takes 10 in binary to be ten.

      Feedback from the catalogue

      The digits 0 and 1 are the same digits, but the place values differ. In base ten each place is worth 10 times the one to its right; in base 2 only twice: from right to left 1,2,4,8,16,…1, 2, 4, 8, 16, \ldots⁠ So 10210_2⁠ is 1×2+0=21 \times 2 + 0 = 2⁠, not ten, and 101121011_2⁠ is 8+2+1=118 + 2 + 1 = 11⁠. When in doubt, write the base as a subscript.

    • Wrong 0101 000020101\,0000_2⁠

      Feedback

      0101 00002=64+16=800101\,0000_2 = 64 + 16 = 80⁠. Start from the largest place that fits: 6464⁠, leaving 3636⁠.

    Feedback for a right answer

    100=64+32+4100 = 64 + 32 + 4⁠, so there is a 1 in the 64s, 32s and 4s places: 0110 010020110\,0100_2⁠.

    Hint

    Take the largest place value that fits away from 100100⁠, then the next, until 00⁠ is left.

    Worked solution

    1. 128128⁠ is more than 100100⁠: bit 0.
    2. 6464⁠ fits: bit 1, leaving 3636⁠.
    3. 3232⁠ fits: 1, leaving 44⁠.
    4. 1616⁠ and 88⁠ do not fit: 0, 0. 44⁠ fits: 1, leaving 00⁠. 22⁠ and 11⁠: 0, 0.
    5. 0110 010020110\,0100_2⁠.

    0000 010020000\,0100_2⁠ is 44⁠: the digits of “a hundred” in base 2 are a different number.

  7. Step 7 of 7

    Open this step

    How many bits you need

    Practice · Calculate

    Question

    You want to give each of 1000 people a different number of their own. How many bits does each number need, at least?

    Correct answer

    10 ± 0.01

    Setup, choices and feedback

    The Scene at this step

    Pixels across
    64 px
    Bits per channel
    8 bit
    Picture / Red, green, blue
    Picture
    Accepted within
    ± 0.01
    A fixed value in the question

    Wrong answers it recognises

    Feedback for a right answer

    29=5122^9 = 512⁠ is too few, and 210=10242^{10} = 1024⁠ is enough: 10 bits. It is also log⁡21000≈9.97\log_2 1000 \approx 9.97⁠, rounded up.

    Hint

    Find the smallest power of 2 that is not less than 10001000⁠.

    Worked solution

    1. Each bit doubles: 28=2562^8 = 256⁠, 29=5122^9 = 512⁠, 210=10242^{10} = 1024⁠.
    2. 512<1000≤1024512 < 1000 \le 1024⁠.
    3. So you need 10 bits.

    If you answered 500500⁠, you took each bit to add two values; it doubles all of them.

Lesson 3 of 4 · About 25 minutes

Colour and hexadecimal

A pixel is three numbers: how many colours so many levels give, bits per pixel, counting in base 16, web colour codes, and light that adds up.

Open the lesson

The 6 steps and their answers
  1. Step 1 of 6

    Open this step

    Three numbers a pixel

    Practice · Calculate

    Question

    The board shows that at this depth a pixel can show 4096 colours. How many levels can each channel, red, green or blue, take?

    Correct answer

    16 ± 0.01

    Setup, choices and feedback

    The Scene at this step

    Pixels across
    64 px
    Bits per channel
    4 bitfixed
    Picture / Red, green, blue
    Picture
    Accepted within
    ± 0.01
    Computed from the Scene at this step’s setting
    Levels each channel can take, 2^bits/nodes/picture/outputs/levels

    Wrong answers it recognises

    • 1365 ± 0.5

      Misconception: Adds or divides the channels' levels instead of multiplying: takes the colours of a pixel to be 3 × the levels.

      Feedback from the catalogue

      A pixel’s colour is a combination of three levels: every level of red can go with every level of green and every level of blue. So the number of colours is a product, L×L×L=L3L \times L \times L = L^3⁠, not 3L3L⁠. At 8 bits per channel: 2563=16,777,216256^3 = 16{,}777{,}216⁠ colours, not 768. Going back from colours to levels takes a cube root, not a division by 33⁠.

    Feedback for a right answer

    16×16×16=409616 \times 16 \times 16 = 4096⁠, so 16 levels, four bits per channel, and 12 bits per pixel in all.

    Hint

    The colours are red’s levels times green’s times blue’s. Which number cubed gives 4096?

    Worked solution

    1. With LL⁠ levels per channel there are L3L^3⁠ colours.
    2. L3=4096L^3 = 4096⁠, so L=40963=16L = \sqrt[3]{4096} = 16⁠.
    3. 16=2416 = 2^4⁠: four bits per channel.

    If you divided by 33⁠, you added the channels instead of multiplying them.

  2. Step 2 of 6

    Open this step

    Bits per pixel

    Practice · Reach the target

    Question

    Change Bits per channel so that a whole pixel, all three of its channels, takes exactly 12 bits, a byte and a half, and press Check.

    Goal

    • 12 ± 0.01

      At the start of the step: 24

    Setup, choices and feedback

    The Scene at this step

    Pixels across
    64 px
    Bits per channel
    8 bit
    Picture / Red, green, blue
    Red, green, blue
    Read from the Scene at
    Bits a pixel takes, 3 channels × bits/nodes/picture/outputs/bitsPerPixel

    One setting that reaches it

    Pixels across
    16 px
    Bits per channel
    4 bit

    Feedback for a right answer

    Four bits for each of the three channels, 3×4=123 \times 4 = 12⁠: 16 levels per channel and 4096 colours.

    Feedback for a wrong answer

    Not yet. A pixel is three channels, and each takes the number of bits on the slider.

    Worked solution

    1. A pixel is three channels: bits per pixel =3×= 3 \times⁠ bits per channel.
    2. 12÷3=412 \div 3 = 4⁠.
    3. Set Bits per channel to 4.
  3. Step 3 of 6

    Open this step

    Base 16

    Practice · Calculate

    Question

    In base 16 the digits are 0 to 9 and then A to F, which are 1010⁠ to 1515⁠. What is FF16\mathrm{FF}_{16}⁠ in base ten?

    Correct answer

    255 ± 0.01

    Setup, choices and feedback

    The Scene at this step

    Pixels across
    64 px
    Bits per channel
    8 bit
    Picture / Red, green, blue
    Red, green, blue
    Accepted within
    ± 0.01
    A fixed value in the question

    Wrong answers it recognises

    Feedback for a right answer

    FF16=15×16+15=255\mathrm{FF}_{16} = 15 \times 16 + 15 = 255⁠, that is 1111 111121111\,1111_2⁠: a full byte. Each hexadecimal digit is exactly four bits, so two of them are a byte.

    Hint

    The left digit is the 16s place and the right one the 1s place.

    Worked solution

    1. F=15\mathrm{F} = 15⁠.
    2. The left digit is worth 16 times as much: 15×16=24015 \times 16 = 240⁠.
    3. 240+15=255240 + 15 = 255⁠.

    15151515⁠ and 3030⁠ forget that the left digit is worth sixteen times as much.

  4. Step 4 of 6

    Open this step

    Colour codes

    Practice · Choose

    Question

    Which colour is #FF8000?

    Correct answer

    • Correct Orange: full red, half green, no blue

    Setup, choices and feedback

    The Scene at this step

    Pixels across
    64 px
    Bits per channel
    8 bit
    Picture / Red, green, blue
    Red, green, blue

    Choices

    Shown in a random order.

    • Correct Orange: full red, half green, no blue

    • Wrong Azure: full blue, half green, no red

      Misconception: Reads a #RRGGBB colour code in the wrong order, as blue, green, red.

      Feedback from the catalogue

      In a web colour code the order is always red, green, blue: the first two digits after the # are red, the middle two green, and the last two blue. #FF8000 is full red, green 128 and no blue: orange. Read backwards it would be a light blue, (0,128,255)(0, 128, 255)⁠.

    • Wrong Grey, since the values average out in the middle

      Feedback

      Grey is three equal channels, like #808080. Here the channels are very different.

    • Wrong Green

      Feedback

      80 is the green, in the middle, but the first FF is full red.

    Feedback for a right answer

    Red FF is 255255⁠, green 80 is 8×16=1288 \times 16 = 128⁠, and blue 00 is 00⁠. Red with half green looks orange.

    Worked solution

    1. Split the code into three pairs: FF, 80, 00, in the order red, green, blue.
    2. FF16=255\mathrm{FF}_{16} = 255⁠, 8016=12880_{16} = 128⁠, 0016=000_{16} = 0⁠.
    3. (255,128,0)(255, 128, 0)⁠: full red and half green, orange.
  5. Step 5 of 6

    Open this step

    Reading a code

    Practice · Calculate

    Question

    In the colour code #3CB371 the two green digits are B3. How strong is the green, in base ten?

    Correct answer

    179 ± 0.01

    Setup, choices and feedback

    The Scene at this step

    Pixels across
    64 px
    Bits per channel
    8 bit
    Picture / Red, green, blue
    Red, green, blue
    Accepted within
    ± 0.01
    A fixed value in the question

    Wrong answers it recognises

    Feedback for a right answer

    B316=11×16+3=179\mathrm{B3}_{16} = 11 \times 16 + 3 = 179⁠, out of 255. It is a medium sea green: red 60, green 179, blue 113.

    Hint

    B=11\mathrm{B} = 11⁠, and it stands in the 16s place.

    Worked solution

    1. B=11\mathrm{B} = 11⁠ and 3=33 = 3⁠.
    2. 11×16=17611 \times 16 = 176⁠.
    3. 176+3=179176 + 3 = 179⁠.

    113113⁠ is “11” and “3” side by side, and 1414⁠ is the digits added.

  6. Step 6 of 6

    Open this step

    Light that adds up

    Practice · Choose

    Question

    A pixel stores red 255, green 255 and blue 0. Which colour do you see on the screen?

    Correct answer

    • Correct Yellow

    Setup, choices and feedback

    The Scene at this step

    Pixels across
    64 px
    Bits per channel
    8 bit
    Picture / Red, green, blue
    Red, green, blue

    Choices

    Shown in a random order.

    • Correct Yellow

    • Wrong Brown, as when you mix red and green paint

      Misconception: Mixes coloured light as if it were paint: expects red and green light to make brown.

      Feedback from the catalogue

      Paint absorbs light, so mixing paints darkens. A screen gives out light: when red and green are lit together the eye receives both and sees yellow, brighter than either. All three at full give white, and all three off give black. This is additive mixing, and it is how a pixel of three small lights shows any colour.

    • Wrong White

      Feedback

      White needs all three lights at full; here the blue is off.

    Feedback for a right answer

    Red and green light together look yellow: a screen adds light, it does not mix paint. Add full blue and you get white.

    Worked solution

    1. Two lights are fully on, red and green, and blue is off.
    2. On a screen the lights add up: the eye receives both.
    3. Red and green together look yellow.

    Paint absorbs light, so mixing it darkens; added light brightens.

Lesson 4 of 4 · About 25 minutes

Images and text as numbers

The size of a picture: resolution, colour depth and bytes, and why doubling the width makes the file four times bigger; and text as numbers, from ASCII to Hebrew letters in UTF-8.

Open the lesson

The 6 steps and their answers
  1. Step 1 of 6

    Open this step

    Resolution

    Practice · Predict, then look

    Question

    The picture is 32 pixels across. When Pixels across doubles to 64, how many times bigger will the uncompressed file be?

    Correct answer

    • Correct 4 times

    Setup, choices and feedback

    The Scene at this step

    Pixels across
    32 pxfixed
    Bits per channel
    8 bitfixed
    Picture / Red, green, blue
    Picture

    Choices

    • Wrong 2 times

      Misconception: Thinks doubling the pixels across doubles the picture's pixels and its size, forgetting that the height doubles too.

      Feedback from the catalogue

      The picture keeps its shape, 4 : 3: when you double the pixels across, the pixels down double as well. The number of pixels is width times height, so it grows 2×2=42 \times 2 = 4⁠ times, and so does the file. It is the same sum as for an area: a square with twice the side is four times as big.

    • Correct 4 times

    • Wrong 8 times

      Feedback

      The width and the height double, but the depth, the bits per channel, stays the same: 2×2=42 \times 2 = 4⁠.

    Once the prediction is locked in, the Scene changes

    Pixels across
    64 pxfixed

    The Scene then shows: 9216 · Uncompressed size in bytes: pixels × 3 channels × bits ÷ 8/nodes/picture/outputs/bytes

    A prediction is never marked as a failure: the learner sees the outcome and the explanation either way.

    Feedback for a right answer

    32×24=76832 \times 24 = 768⁠ pixels become 64×48=307264 \times 48 = 3072⁠, four times as many, and the file grows from 2304 bytes to 9216.

    Worked solution

    1. The picture keeps its 4 : 3 shape, so the height doubles with the width: from 2424⁠ to 4848⁠.
    2. Pixels: 32×24=76832 \times 24 = 768⁠ before, 64×48=307264 \times 48 = 3072⁠ after, 4 times as many.
    3. Each pixel takes the same three bytes, so the file grows 4 times too.
  2. Step 2 of 6

    Open this step

    The file size

    Practice · Calculate

    Question

    The picture is 64×4864 \times 48⁠ pixels, at 8 bits per channel, and the board rounds its size to kilobytes. Exactly how many bytes does it take uncompressed?

    Correct answer

    9216 ± 0.01

    Setup, choices and feedback

    The Scene at this step

    Pixels across
    64 pxfixed
    Bits per channel
    8 bitfixed
    Picture / Red, green, blue
    Picture
    Accepted within
    ± 0.01
    Computed from the Scene at this step’s setting
    Uncompressed size in bytes: pixels × 3 channels × bits ÷ 8/nodes/picture/outputs/bytes

    Wrong answers it recognises

    • 3072 ± 0.01

      Misconception: Stores one number per pixel, forgetting its three channels.

      Feedback from the catalogue

      A colour pixel is three numbers: red, green and blue. In true colour each of them is a byte, so a pixel takes three bytes, 24 bits. The uncompressed size of a picture is the number of pixels times 33⁠ times the bits per channel, divided by 88⁠.

    • 73730 ± 0.01

      Misconception: Mixes up bits and bytes: gives a size in bits as bytes, off by a factor of 8.

      Feedback from the catalogue

      A byte is eight bits. File sizes are measured in bytes (B, kB, MB), and network speeds usually in bits per second (Mbit/s). To go from bits to bytes, divide by 88⁠; from bytes to bits, multiply by 88⁠. An answer eight times too big is nearly always a count of bits.

    Feedback for a right answer

    64×48=307264 \times 48 = 3072⁠ pixels, ×3=9216\times 3 = 9216⁠ bytes, about 9.2 kB. A phone photo, 4000×30004000 \times 3000⁠ pixels, would take 36 MB this way, which is why photos are stored compressed.

    Hint

    Pixels, times three channels, times a byte per channel.

    Worked solution

    1. Pixels: 64×48=307264 \times 48 = 3072⁠.
    2. Each pixel is three channels of a byte: 3 bytes.
    3. 3072×3=92163072 \times 3 = 9216⁠ bytes.

    30723072⁠ forgets the three channels, and 73,72873{,}728⁠ is the size in bits.

  3. Step 3 of 6

    Open this step

    Resolution against colour

    Practice · Reach the target

    Question

    You need a small icon that takes exactly 576 bytes, at 2 bits per channel. Change Pixels across and Bits per channel until it does, and press Check.

    Goal

    • 576 ± 0.01

      At the start of the step: 9216

    • 6 ± 0.01

      At the start of the step: 24

    Setup, choices and feedback

    The Scene at this step

    Pixels across
    64 px
    Bits per channel
    8 bit
    Picture / Red, green, blue
    Picture
    Read from the Scene at
    Uncompressed size in bytes: pixels × 3 channels × bits ÷ 8/nodes/picture/outputs/bytes
    Read from the Scene at
    Bits a pixel takes, 3 channels × bits/nodes/picture/outputs/bitsPerPixel

    One setting that reaches it

    Pixels across
    32 px
    Bits per channel
    2 bit

    Feedback for a right answer

    32×24=76832 \times 24 = 768⁠ pixels, times 6 bits, is 4608 bits, that is 576 bytes. The same size also fits 16×1216 \times 12⁠ in true colour: fewer pixels and more colours.

    Feedback for a wrong answer

    Not yet. Set 2 bits per channel first, then find the width.

    Hint

    At 2 bits per channel a pixel takes 6 bits. How many pixels fit in 576×8576 \times 8⁠ bits?

    Worked solution

    1. 576 bytes are 576×8=4608576 \times 8 = 4608⁠ bits.
    2. At 2 bits per channel a pixel takes 3×2=63 \times 2 = 6⁠ bits, so there are 4608÷6=7684608 \div 6 = 768⁠ pixels.
    3. At 4 : 3: 32×24=76832 \times 24 = 768⁠.
    4. Set Pixels across to 32 and Bits per channel to 2.
  4. Step 4 of 6

    Open this step

    Letters as numbers

    Practice · Calculate

    Question

    In ASCII each character is a number, and the capital letters come in order: A is 6565⁠, B is 6666⁠. Which number stores the letter D?

    Correct answer

    68 ± 0.01

    Setup, choices and feedback

    The Scene at this step

    Pixels across
    64 px
    Bits per channel
    8 bit
    Picture / Red, green, blue
    Picture
    Accepted within
    ± 0.01
    A fixed value in the question

    Feedback for a right answer

    68=0100 0100268 = 0100\,0100_2⁠. The computer stores no shape for the letter, only its number; the font draws it on the screen.

    Worked solution

    1. A, B, C, D: D is three letters after A.
    2. 65+3=6865 + 3 = 68⁠.
  5. Step 5 of 6

    Open this step

    A word

    Practice · Choose

    Question

    How many bytes does the word HELLO take in ASCII?

    Correct answer

    • Correct 5

    Setup, choices and feedback

    The Scene at this step

    Pixels across
    64 px
    Bits per channel
    8 bit
    Picture / Red, green, blue
    Picture

    Choices

    Shown in a random order.

    • Correct 5

    • Wrong 40

      Misconception: Mixes up bits and bytes: gives a size in bits as bytes, off by a factor of 8.

      Feedback from the catalogue

      A byte is eight bits. File sizes are measured in bytes (B, kB, MB), and network speeds usually in bits per second (Mbit/s). To go from bits to bytes, divide by 88⁠; from bytes to bits, multiply by 88⁠. An answer eight times too big is nearly always a count of bits.

    • Wrong 1, one word

      Feedback

      The computer does not know what a word is; it stores each character separately, the second L too.

    Feedback for a right answer

    Five characters, a byte each: 72,69,76,76,7972, 69, 76, 76, 79⁠. That is 40 bits in all.

    Worked solution

    1. In ASCII each character takes one byte.
    2. HELLO has five characters.
    3. 55⁠ bytes, which are 5×8=405 \times 8 = 40⁠ bits.
  6. Step 6 of 6

    Open this step

    Every language

    Practice · Choose

    Question

    In UTF-8, the encoding of most of the web, how many bytes does the Hebrew word שלום (four letters) take?

    Correct answer

    • Correct 8

    Setup, choices and feedback

    The Scene at this step

    Pixels across
    64 px
    Bits per channel
    8 bit
    Picture / Red, green, blue
    Picture

    Choices

    Shown in a random order.

    • Correct 8

    • Wrong 4, a byte per letter

      Misconception: Assumes every character takes one byte, as in ASCII, including Hebrew letters.

      Feedback from the catalogue

      ASCII has only 128 characters, Latin letters, digits and signs, and each fits in a byte. To write every language, Unicode gives a number to every character in the world, more than a hundred thousand, and that no longer fits in one byte. In the UTF-8 encoding a Latin character is still one byte, a Hebrew letter is two bytes, and an emoji is four.

    • Wrong 64

      Misconception: Mixes up bits and bytes: gives a size in bits as bytes, off by a factor of 8.

      Feedback from the catalogue

      A byte is eight bits. File sizes are measured in bytes (B, kB, MB), and network speeds usually in bits per second (Mbit/s). To go from bits to bytes, divide by 88⁠; from bytes to bits, multiply by 88⁠. An answer eight times too big is nearly always a count of bits.

    Feedback for a right answer

    Each Hebrew letter in UTF-8 is two bytes, so four letters are 8 bytes. ש is character number 1513 in Unicode, too big to fit in one byte.

    Worked solution

    1. One byte has only 256256⁠ values, and Unicode needs a number for every character in every language.
    2. In UTF-8 a Latin character is one byte, and a Hebrew letter two.
    3. שלום is four letters: 4×2=84 \times 2 = 8⁠ bytes.

    6464⁠ is the size in bits.

Across the unit · 13 misconceptions

Misconception catalogue

Each common mistake this unit recognises, in a few words. Open one for what the learner reads when an answer matches it, and where it is asked.

  • Confuses the largest value with how many values there are, forgetting that counting starts at 0.

    The learner reads

    A computer counts from 00⁠. Two bits have four patterns, 00, 01, 10 and 11, and they are the numbers 00⁠ to 33⁠: four numbers, the largest of which is 33⁠. In general nn⁠ bits give 2n2^n⁠ values, the largest being 2n−12^n - 1⁠. So a byte, 8 bits, holds 256 values, from 00⁠ to 255255⁠.

  • Thinks each extra bit adds a fixed number of values instead of doubling them (2 bits give 2, 8 bits give twice what 4 give).

    The learner reads

    Each extra bit doubles the number of values: every pattern of the earlier bits appears once with a 0 in the new bit and once with a 1. So nn⁠ bits give 2×2×⋯×2=2n2 \times 2 \times \cdots \times 2 = 2^n⁠ values: 4 bits give 16, and 8 bits give not 32 but 16×16=25616 \times 16 = 256⁠.

  • Reads a binary numeral as if it were decimal: takes 10 in binary to be ten.

    The learner reads

    The digits 0 and 1 are the same digits, but the place values differ. In base ten each place is worth 10 times the one to its right; in base 2 only twice: from right to left 1,2,4,8,16,…1, 2, 4, 8, 16, \ldots⁠ So 10210_2⁠ is 1×2+0=21 \times 2 + 0 = 2⁠, not ten, and 101121011_2⁠ is 8+2+1=118 + 2 + 1 = 11⁠. When in doubt, write the base as a subscript.

  • Gives the rightmost bit the largest place value, reading the number back to front.

    The learner reads

    As in decimal numbers, the rightmost digit is the ones, and the place values grow to its left. In base 2 the rightmost bit is worth 11⁠, the next 22⁠, then 44⁠, 88⁠ and so on. On the board’s switches A is the 2s place and B the 1s place, so the number 22⁠ is A = 1, B = 0. Read backwards, 11012=131101_2 = 13⁠ turns into 10112=111011_2 = 11⁠.

  • Takes the value of a binary number to be the number of 1s in it.

    The learner reads

    Each 1 adds its place value, not 11⁠. 101121011_2⁠ has three 1s, but they stand in the places of 88⁠, 22⁠ and 11⁠, so the value is 8+2+1=118 + 2 + 1 = 11⁠. And 10210_2⁠, with a single 1, is 22⁠, because that 1 stands in the 2s place.

  • Adds or divides the channels' levels instead of multiplying: takes the colours of a pixel to be 3 × the levels.

    The learner reads

    A pixel’s colour is a combination of three levels: every level of red can go with every level of green and every level of blue. So the number of colours is a product, L×L×L=L3L \times L \times L = L^3⁠, not 3L3L⁠. At 8 bits per channel: 2563=16,777,216256^3 = 16{,}777{,}216⁠ colours, not 768. Going back from colours to levels takes a cube root, not a division by 33⁠.

  • Reads each hexadecimal digit as a decimal number and writes them side by side, or adds them, ignoring that the left digit is worth 16 times as much.

    The learner reads

    In base 16 each digit is worth 00⁠ to 1515⁠ (A to F are 1010⁠ to 1515⁠), and the left digit is worth 16 times the right one. So FF16=15×16+15=255\mathrm{FF}_{16} = 15 \times 16 + 15 = 255⁠: not “15 15” and not 15+1515 + 15⁠. Likewise B316=11×16+3=179\mathrm{B3}_{16} = 11 \times 16 + 3 = 179⁠. Two hexadecimal digits are exactly one byte, 00⁠ to 255255⁠.

  • Reads a #RRGGBB colour code in the wrong order, as blue, green, red.

    The learner reads

    In a web colour code the order is always red, green, blue: the first two digits after the # are red, the middle two green, and the last two blue. #FF8000 is full red, green 128 and no blue: orange. Read backwards it would be a light blue, (0,128,255)(0, 128, 255)⁠.

  • Mixes coloured light as if it were paint: expects red and green light to make brown.

    The learner reads

    Paint absorbs light, so mixing paints darkens. A screen gives out light: when red and green are lit together the eye receives both and sees yellow, brighter than either. All three at full give white, and all three off give black. This is additive mixing, and it is how a pixel of three small lights shows any colour.

  • Thinks doubling the pixels across doubles the picture's pixels and its size, forgetting that the height doubles too.

    The learner reads

    The picture keeps its shape, 4 : 3: when you double the pixels across, the pixels down double as well. The number of pixels is width times height, so it grows 2×2=42 \times 2 = 4⁠ times, and so does the file. It is the same sum as for an area: a square with twice the side is four times as big.

  • Stores one number per pixel, forgetting its three channels.

    The learner reads

    A colour pixel is three numbers: red, green and blue. In true colour each of them is a byte, so a pixel takes three bytes, 24 bits. The uncompressed size of a picture is the number of pixels times 33⁠ times the bits per channel, divided by 88⁠.

  • Mixes up bits and bytes: gives a size in bits as bytes, off by a factor of 8.

    The learner reads

    A byte is eight bits. File sizes are measured in bytes (B, kB, MB), and network speeds usually in bits per second (Mbit/s). To go from bits to bytes, divide by 88⁠; from bytes to bits, multiply by 88⁠. An answer eight times too big is nearly always a count of bits.

  • Assumes every character takes one byte, as in ASCII, including Hebrew letters.

    The learner reads

    ASCII has only 128 characters, Latin letters, digits and signs, and each fits in a byte. To write every language, Unicode gives a number to every character in the world, more than a hundred thousand, and that no longer fits in one byte. In the UTF-8 encoding a Latin character is still one byte, a Hebrew letter is two bytes, and an emoji is four.

Index