← Teacher guide

How many patterns?

Students count up on binary cards to find that n bits make 2ⁿ patterns and hold 0 to 2ⁿ − 1, see a count overflow, and choose how many bits a number needs (AC9TDI8K04).

Data representation · Binary numbers · about 40 minutes · Open the student lesson

Classroom resources

Open these in Waypoints Prepare with one click. To share a file another way, copy its address and paste it into Load URL, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.

Students will be able to

Timing

Predict and Try 8 min · Worked example 10 min · Vary 12 min · Practise and Make 10 min

Before class

Do the Try and Vary boards yourself first. Students need Bits and binary numbers (reading binary) and powers of 2 from maths.

The one idea: each extra bit doubles the number of patterns, so nn bits make 2n2^n patterns, and because one pattern is 0, the largest number is 2n−12^n - 1. Overflow is what happens when you count past it.

Real examples worth a minute: colour values 0 to 255 (one byte each); the micro:bit LED brightness 0 to 255; game scores and counters that wrapped round. Students who have done Arcade or micro:bit can look for 255 limits in the blocks.

Running the lesson

  1. Predict: students who chose 16 counted the patterns but forgot 0; 4 counted the cards.
  2. Try: ask how many presses it took to get from 0 to 1111, and how many patterns that makes.
  3. Worked example: pause before line 3 and ask why we multiply, not add.
  4. Vary: before Add a card, ask students to predict the new card's value and the new biggest number.
  5. Make: have students say the range first (0 to 39), then the bits.

In class

On the slides at these points. Students can do the whole lesson on their own; these are for the room. In the deck, the Run, Modify and Make slides have the live playground in them (the tutorial link is the backup), and the notes above are in each slide's speaker notes.

The hard part (on purpose)

Forgetting that one pattern is 0, so saying 4 bits go up to 16. Ask "what do the cards show when they are all face down?" every time a largest number comes up.

When students get stuck

What you will seeA question to askThe fix
A student says 4 bits hold 1 to 16 (Sam's mistake).What number do the cards show when they are all face down?0 is one of the patterns, so the 16 patterns are 0 to 15.
A student says 10 bits make 20 patterns.What happens to the patterns when you add one card?Each card doubles them: 2, 4, 8, 16, …, so multiply.
A student thinks overflow is an error message.What does + 1 do to 1111 if there is no fifth card?Every card flips down: the computer just loses the carry.

Answers to the checks

  1. the biggest number: You have four cards, worth 8, 4, 2 and 1. What is the **biggest** number they can show?
    15. All four cards face up: 8 + 4 + 2 + 1 = 15. There are 16 patterns, but one of them is 0, so the biggest is 15. 1111 is 15 written in binary.
  2. Try: count up: Press + 1 to count up until every card is face up. What number is it?

    1111 = 8 + 4 + 2 + 1 = 15. Counting from 0, that took 15 presses, so with 0 there are 16 patterns.
  3. Count the patterns: What is the biggest number **five** bits can show?
    31
    11111 = 16 + 8 + 4 + 2 + 1 = 31. Five bits make 2⁵ = 32 patterns: 0 to 31.
  4. Find the mistake: Sam works out how many numbers 4 bits can show. Click the line where the working first goes wrong.
    line 4
    Line 4: the 16 patterns are 0000 to 1111, so the numbers are 0 to 15. Sam left out 0 (all cards face down).
  5. Three bits: How many different patterns can **three** bits make?
    8
    2 × 2 × 2 = 8 patterns: 000, 001, 010, 011, 100, 101, 110, 111. That is 0 to 7.
  6. One past the biggest: The board shows 1111, which is 15. Press + 1 once. What happens to the cards?

    Every card went face down and the count went back to 0. Four bits cannot show 16, so the count overflows.
  7. Add a card: Press Add a card. What is the new card worth? Make the biggest number five cards can show.

    The new card is worth 16, double the 8. All five up: 16 + 8 + 4 + 2 + 1 = 31.
  8. Six cards: Add one more card and make the biggest number six cards can show.

    The new card is worth 32. 32 + 31 = 63, which is 2⁶ − 1.
  9. A byte: Eight bits are called a **byte**. What is the biggest number a byte can hold?
    255
    2⁸ = 256 patterns, so a byte holds 0 to 255.
  10. How many bits?: What is the **fewest** bits that can hold the number 100?
    7
    Six bits hold 0 to 63, seven bits hold 0 to 127. 100 needs seven bits.
  11. Ten bits: How many different patterns can **ten** bits make?
    1024
    210=10242^{10} = 1024 patterns, so ten bits hold 0 to 1023.
  12. Score overflow: An old game stores the score in one byte. The score is 255 and the player scores 1 more point. What does the score show?
    0
    255 is 11111111. Adding 1 overflows: every bit flips to 0 and the score shows 0. Real games have had bugs like this.
  13. Colour values: In many programs, the amount of red in a colour goes from 0 to 255. How many bits store it?
    8
    0 to 255 is 256 values, and 28=2562^8 = 256. So each colour amount is one byte.
  14. Three bits: What is the biggest number **three** bits can show?
    7
    111 = 4 + 2 + 1 = 7.
  15. Review: read binary: Review: what number is **10101** in binary?
    21
    10101 = 16 + 4 + 1 = 21.
  16. enough bits: A school gives each student in a group an ID number from 0 to 39. Use the fewest cards that can show 39, then set them to 39.

    Five cards stop at 31, so you need six (0 to 63). 39 = 32 + 4 + 2 + 1, so 100111.

Solutions

One possible solution for each task. Other correct programs are fine.

Vary: one change at a time › One past the biggest

Open task: any program that does what the step asks.

Vary: one change at a time › Add a card

Open task: any program that does what the step asks.

Vary: one change at a time › Six cards

Open task: any program that does what the step asks.

Vary: one change at a time › A byte

Open task: any program that does what the step asks.

Vary: one change at a time › How many bits?

Open task: any program that does what the step asks.

enough bits

Open task: any program that does what the step asks.

Stretch and support

Stretch: How many bits would you need to give every person on Earth (about 8 billion) a different number? (33: 2³² is about 4.3 billion, 2³³ about 8.6 billion.)

Support: Keep a doubling table beside the board: bits 1 to 8, patterns 2 to 256, biggest 1 to 255.

Exit ticket

How many patterns can 6 bits make, and what is the biggest number they can hold?

2⁶ = 64 patterns, so 0 to 63. The biggest is 63.

What each step is for

Where it leads

Builds on: the data as numbers lessons. Colour amounts (0 to 255) are one byte each, and 16-bit audio has 2¹⁶ = 65 536 levels: ask students to explain both now.

Where it leads: data sizes (bytes, kilobytes) and, in Years 9–10, compression.

Sources