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).
Load these into Waypoints Prepare: choose Load URL and paste the copied address, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.
SlidesDownload Present from the browser, or export to PowerPoint or PDF.
WorksheetDownload Print the student copy; the Teacher edition has the answers.
Students will be able to
I can say how a word is stored as numbers.
I can find the code of a letter, a space or a digit.
I can explain why some characters need more than one byte.
Timing
Predict and Try 6 min · Worked example 10 min · Vary 9 min · Practise and Make 10 min
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
What you will see
A question to ask
The fix
A student writes 7 for the digit 7 (Sam's mistake).
What does the board show when you type 7?
In text a digit is a character: 0 is 48, so 7 is 55.
A student forgets the space.
How many characters are in hi there, counting the gap?
The space is a character too: 32.
A student can't find a lower case code.
What is the capital's code?
Add 32.
Answers to the checks
how is CAB stored?: In text, **A** is stored as 65 and **B** as 66. How is the word **CAB** stored? 67, 65, 66. Each character has its own code, and the capital letters count on from A = 65, so C is 67. The computer stores only the numbers.
Try: type a word: Type CAB in the box. What numbers are stored?
C is 67, A is 65, B is 66: one code for each character, in the order you typed them.
Encode Hi 7!: Lower case letters start at a = 97. What number stores lower case **c**? 99 a is 97, b is 98, c is 99. Each lower case letter is 32 more than its capital (C is 67).
Find the mistake: Sam stores the text "Year 7" as numbers. Click the line where the working first goes wrong. line 4 Line 4: in text, the 7 is a character like any other, and its code is 55 (the digits start at 0 = 48). 7 is the code for a control character, not the digit.
Capital or lower case?: Why do **A** and **a** have different codes? They are different characters, so the computer must be able to tell them apart A and a look different and mean different things in passwords and names, so each has its own code. That is why passwords are case sensitive.
Lower case: Type cab in lower case. How did the codes change?
Each code went up by 32: c is 99, a is 97, b is 98.
One capital: Now type Cab: only the first letter is a capital.
Only the first code changed back to 67.
A digit: Type just the digit 7.
The digit 7 is stored as 55. To the computer, a digit in text is a character, not an amount.
A space: Type two words with a space between them, such as hi there.
The space is stored as 32, between the codes of the two words.
Beyond A to Z: Type an emoji or an accented letter such as é or ñ. What happens to the code?
These characters have codes too, from Unicode, which gives codes to over a hundred thousand characters. Codes above 255 do not fit in one byte (0 to 255), so they are stored in two to four bytes.
Last letter: Capital letters run from A = 65. What is the code for **Z**? 90 65 + 25 = 90.
A list of codes: Which list stores the text **Go 2**? 71, 111, 32, 50 G 71, o 111, space 32, digit 2 is 50.
Passwords: Your password is **cat** but you type **Cat**. Why does it fail? C is stored as 67 but c is 99, so the codes don't match The computer compares codes, and 67 is not 99.
Code to character: What character has the code 97 + 25 = 122? z 97 is a, so 97 + 25 is the 26th lower case letter, z.
Review: same numbers: Review: a text file holds 72, 105. A paint program opens it. What does it show? Two shades of grey The same numbers, read with a different rule: two dark greys.
change case with numbers: The board shows HI (72, 73). Change only the numbers so the text reads hi in lower case.
Each lower case letter is 32 more than its capital: 72 + 32 = 104 (h) and 73 + 32 = 105 (i).
Solutions
One possible solution for each task. Other correct programs are fine.
Vary: change one character › Lower case
Open task: any program that does what the step asks.
Vary: change one character › One capital
Open task: any program that does what the step asks.
Vary: change one character › A digit
Open task: any program that does what the step asks.
Vary: change one character › A space
Open task: any program that does what the step asks.
Vary: change one character › Beyond A to Z
Open task: any program that does what the step asks.
change case with numbers
Open task: any program that does what the step asks.
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.
Exit ticket
Write the codes for the text Hi 5.
72, 105, 32, 53 (the digit 5 is 48 + 5).
What each step is for
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.
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).