Students see that 12 typed as text is two characters with their own codes, compare adding numbers with joining text, and choose number or text for each box on a sign-up form (AC9TDI6K03 node 2).
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.
WorksheetOpen in PrintDownload Print the student copy; the Teacher edition has the answers.
Students will be able to
I can say what a computer does with numbers and with text.
I can explain why 12 and 3 can make 15 or 123.
I can choose whether a form should store something as a number or as text.
Timing
Predict and Try 6 min · Worked example 10 min · Vary 6 min · Practise and Make 13 min
Before class
Do the Try board yourself: type 12, then 123.
The one idea: the type of data (number or text) decides what the computer can do with it. Numbers add; text joins.
Simplification: in programs this is "string" and "integer"; spreadsheets show it as a number lined up on the right and text on the left. Neither word is needed here.
Year 7–8 catch-up: Text as numbers (8K03 n2) assumes students know a digit in text is a character; this lesson is that idea.
Running the lesson
Predict: students who chose 15 added; ask what joining two words does.
Try: ask why 12 needs two numbers here but would need one as a number.
Worked example: ask what goes wrong if a phone number loses its 0.
Make: let pairs argue about year level; adding 1 next year is the deciding job.
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.
Think, pair, share(start) Your phone number is digits. Should a computer store it as a number or as text?
Would you ever add two phone numbers?
What happens to the 0 at the front if it's stored as a number?
Text: no maths is ever done with it, and a number would drop the leading 0 (0412 becomes 412). The rule students should leave with: will we do maths with it? Then a number. If not, text.
Join or add?(predict, 3 min)
Two cards: 12 and 3. One group joins them like words (put them side by side). The other adds them. Compare.
123 and 15. Same keys, different jobs. The board shows why: as text, 12 is two characters.
Year level: number or text?(make, 3 min)
Stand on the left if year level should be a number, on the right if text. Be ready to say what the club will do with it.
Either is defensible until someone says 'next year we add 1'. That job makes it a number.
Which type?(investigate) A shop's app adds up prices for a total. How should it store each price? As a number It does maths with prices, so they're numbers.
The hard part (on purpose)
Thinking text that looks like a number is a number. Have them type 12 on the board and count the codes.
When students get stuck
What you will see
A question to ask
The fix
A student says the computer adds text that looks like numbers (Sam's mistake).
What does joining cat and fish make? Now join 12 and 3.
Text joins; only numbers add.
A student says a phone number is a number.
Would you ever add two phone numbers?
No maths, and the leading 0 must stay: text.
Answers to the checks
join or add?: A form has two text boxes. Ana types 12 in one and 3 in the other. The form joins the two pieces of text together. What does it show? 123. Joining text puts one piece after the other. Only numbers get added.
Try: type 12 as text: Type 12 in the box. How many numbers does the computer store for it?
Two: 49 for the character 1 and 50 for the character 2. As text, 12 is two characters in a row, like the letters in a word.
12 and 3, two ways: Which can the computer add up to make a total? 12 stored as a number Numbers can be added, taken away and sorted by size. Text can be joined and sorted A to Z.
Find the mistake: Sam joins two text boxes. Click the line where it first goes wrong. line 3 Line 3: text is stored as codes, but the computer doesn't add text. It joins it, so the box shows 123.
Phone numbers: Why is a phone number like 0412 345 678 stored as text? You never add them, and the 0 at the front must stay As a number, 0412 would lose its 0 and become 412. As text, every character stays.
Add: 5 and 4 are stored as numbers. The computer adds them. What does it show? 9 As numbers they add: 5 + 4 = 9.
Join: Now 5 and 4 are stored as text. The computer joins them. What does it show? 54 As text they join: 5 then 4, which is 54.
Join words: cat and fish are stored as text. The computer joins them. What does it show? catfish Text joins: catfish.
Score: A game keeps your score and adds 10 every time you win. How should it store the score? As a number The game does maths with it, so it's a number.
Names: A class list sorts names from A to Z. What type are the names? Text Names are text: sorted A to Z by their letter codes, never added.
Review: codes: Review: A is 65. What number is the letter F? 70 Count on five from 65.
design a sign-up form: You're making the sign-up form for the Coding Club. For each box, choose how to store it. How many robots each member built → Number: we'll do maths with it; Member's name → Text: we won't; Parent's phone number → Text: we won't; Postcode → Text: we won't; Points earned this term → Number: we'll do maths with it; Year level → Number: we'll do maths with it Ask: will the program do maths with it? Then it's a number. If not, text keeps every character just as it was typed.
Stretch and support
Stretch: A spreadsheet shows 0412 as 412. What happened, and how could you stop it?
Support: A card: Number: add, take away, compare sizes. Text: join, sort A to Z, keep every character.
Exit ticket
A and B are 5 and 6. As numbers, what do they make together? As text?
11 (added); 56 (joined).
What each step is for
join or add?: Committing to what joining two pieces of text shows tests the new move: text is joined, not added.
Try: type 12 as text: Typing 12 as text and seeing two codes settles the prediction: as text, 12 is two characters, not the number twelve.
Worked example: same keys, different jobs: Doing 12 and 3 both ways models the move. Sam adds two pieces of text, the mistake planted after the method.
Vary: what happens?: Each task changes the type or the job: add numbers, join text, then join words.
which type?: Choosing the type from what the program will do with it, and a review of letter codes.
design a sign-up form: Sorting a form's boxes by what the program will do with them reverses the move: students choose the type.
Where it leads
Next: On or off (how switches store numbers).
Year 7–8: Everything is numbers; in Code, Python console › Text into numbers (int()).