Text is stored as a list of numbers, one for each character. Every character has its own code: A is 65, a is 97, a space is 32 and even the digit 7 has a code (55). Unicode gives codes to over a hundred thousand characters, including emoji.
Every message you send is stored as a list of numbers. What list is your name?
In Everything is numbers, the numbers 72, 105, 33 were read as the text Hi!. Text is stored that way: as a list of numbers, one for each character (a letter, digit, space or symbol). Each character's number is its code.
Predict: Read the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.
Try: Try it on the board and compare the result with your prediction.
Investigate: Work out why it happens, one step at a time.
Modify: Change the problem on purpose and see what happens.
Practise: A few on your own, to check you have it.
Make: Make your own problem using what you have learned. Expect a few tries; that is normal.
Make your prediction first. Help opens once you've locked it in.
PredictRead the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.
How is CAB stored?
TryTry it on the board and compare the result with your prediction.
Try: type a word
Was your prediction right? Now try your name.
Try it yourselfYour edits are saved in this browser.
Type CAB in the box. What numbers are stored?
Use the board. This ticks when you get there.
InvestigateWork out why it happens, one step at a time.
Worked example: Hi 7!
Worked exampleBefore each step, say what you think comes next.
H→72Capital letters start at A = 65. H is the 8th letter: 65 + 7.
i→105Lower case has its own codes, starting at a = 97. Each is 32 more than its capital (I is 73).
space→32A space is a character too, so it has a code.
7→55The digit 7 is a character. Digits start at 0 = 48, so 7 is 55.
!→33Symbols have codes as well.
Hi 7!→72,105,32,55,33Text is the list of codes, in order.
Now find lower case c.
Lower case letters start at a = 97. What number stores lower case **c**?
Sam stores the text "Year 7" as numbers. Click the line where the working first goes wrong.
ModifyChange the problem on purpose and see what happens.
Vary: change one character
Try it yourselfYour edits are saved in this browser.
Type cab in lower case. How did the codes change?
Use the board. This ticks when you get there.
Now type Cab: only the first letter is a capital.
Use the board. This ticks when you get there.
Type just the digit 7.
Use the board. This ticks when you get there.
Type two words with a space between them, such as hi there.
Use the board. This ticks when you get there.
Type an emoji or an accented letter such as é or ñ. What happens to the code?
Use the board. This ticks when you get there.
PractiseA few on your own, to check you have it.
Codes
Capital letters run from A = 65. What is the code for **Z**?
MakeMake your own problem using what you have learned. Expect a few tries; that is normal.
Change case with numbers
Stretch: the Caesar cipher in Secret messages adds the same number to every code. What would adding 1 to every code in HI make?
Try it yourselfYour edits are saved in this browser.
Need a hint?
Lower case is 32 more than its capital.
Another hint
H is 72, so h is 72 + 32.
Another hint
Change 72 to 104 and 73 to 105.
The board shows HI (72, 73). Change only the numbers so the text reads hi in lower case.
Use the board. This ticks when you get there.
For teachers
Students type words and read their character codes to see that text is a list of codes, one per character, including spaces, digits and lower case, and that Unicode gives codes to every character (AC9TDI8K03 node 2). About 35 minutes.
I can find the code of a letter, a space or a digit.
I can explain why some characters need more than one byte.
Before class
Do the Try board yourself: type a few words, then an emoji.
The one idea: text is a list of character codes, in order. The codes here are ASCII, which Unicode keeps for the first 128 characters; Unicode then gives codes to every script and to emoji. Bytes come up as "0 to 255 fits in one byte"; the binary lessons explain why.
Links: Secret messages (Code pathway) builds ciphers that shift these codes; this lesson is the theory those lessons assume.
Running the lesson
Predict: students who chose 3, 1, 2 used alphabet positions; ask what A's code is.
Try: have everyone type their first name and compare: whose code list is longest?
Worked example: before the 7 line, ask what the digit's code will be.
Vary: ask why the emoji's code is so big.
Make: ask what rule they used to turn capitals into lower case.
The hard part (on purpose)
Students treat a digit in text as an amount (7 stored as 7). Have them type 7 on the board and read the code aloud before the Worked example.
When students get stuck
A student writes 7 for the digit 7 (Sam's mistake). Ask: What does the board show when you type 7? Fix: In text a digit is a character: 0 is 48, so 7 is 55.
A student forgets the space. Ask: How many characters are in hi there, counting the gap? Fix: The space is a character too: 32.
A student can't find a lower case code. Ask: What is the capital's code? Fix: Add 32.
Stretch and support
Stretch: Look up the Unicode code for an emoji you like (or type it on the board). Why do emoji make text messages bigger?
Support: Give the code table: A = 65 … Z = 90, a = 97 … z = 122, 0 = 48 … 9 = 57, space = 32.
Where it leads
Next: Colour and images (each pixel is numbers).
Where it leads: Secret messages (shifting codes to make a cipher), and the binary lessons (why one byte holds 0 to 255).
how is CAB stored?: Committing to how a word is stored shows whether students expect one code per character (and A = 65 counting on), alphabet positions, or the letters themselves stored.
Try: type a word: Typing CAB and reading the codes settles the prediction: one code per character, in order.
Worked example: Hi 7!: Encoding Hi 7! one character at a time models the new move, including the cases students forget: lower case has its own codes, a space is a character, and a digit is a character with a code. Sam stores the digit 7 as 7, the misconception planted after the method.
Vary: change one character: Each task changes one thing in the typed text: case, one letter, a digit, a space, then a character beyond one byte (Unicode).
codes: Codes both ways, a digit and a space, case in passwords, and a review that the same numbers read as another kind of data mean something else.
change case with numbers: Changing the codes to turn HI into hi, without typing, reverses the process: students use the rule (lower case is 32 more) to set the numbers directly.
Now you can
Say how a word is stored as numbers.
Find the code of a letter, a space or a digit.
Explain why some characters need more than one byte.