Text data: character and string

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Text data: character and string

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which one is a single character?
A 'Ace'
B 'A'
2. Which one is a string?
A S
B 'Sam'
3. How should a phone number such as 0412 345 678 be stored?
A As a string, '0412345678'
B As a number, 412345678
4. Which value is text data (a string)?
A '2025'
B 2025
5. True or false: the digit '7' in quotes is a character, not a number.
A True
B False

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1'A' A'0412345678'
2'Sam Lee' BThe phone number has no quotes, so it is treated as a number and the leading zero is lost. It should be '0412345678'.
3A phone number is stored as a string so the leading zero is kept CA string: a sequence of characters, including a space, stored as text
4A single symbol is a character, even though it is not a letter DThe text has no quotes, so it is not recognised as a string. It should be 'Sam'.
5phone = 0412345678 EA single character (one letter) written in quotes
6name = Sam F'#'

Definitions

string

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
Field: Phone Data type: ____
2.
_____ = "0412345678" print(phone)
3.
print(___("0412345678"))
4.
Initial: Character Name: ______
5.
print("04" _ "12")

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A name = "Sam"
B initial = "S"
C phone = 0412345678
D print(phone)
Question 2
A mobile = "0412 345 678
B print(mobile)
C print(len(mobile))
Question 3
A letter = "B"
B word = Bandicoot
C print(letter)
D print(word)
Question 4
A first = "Alex"
B last = "Nguyen"
C space = " "
D full = first - space - last
E print(full)
Question 5
A a = "7"
B b = "5"
C c = a + b
D print("c")

Answer Key

Text data: character and string
Section A: Quick Questions
Q1
B — 'A'
Q2
B — 'Sam'
Q3
A — As a string, '0412345678'
Q4
A — '2025'
Q5
A — True
Section B: Match the Pairs
Q1
'A' → A single character (one letter) written in quotes
Q2
'Sam Lee' → A string: a sequence of characters, including a space, stored as text
Q3
A phone number is stored as a string so the leading zero is kept → '0412345678'
Q4
A single symbol is a character, even though it is not a letter → '#'
Q5
phone = 0412345678 → The phone number has no quotes, so it is treated as a number and the leading zero is lost. It should be '0412345678'.
Q6
name = Sam → The text has no quotes, so it is not recognised as a string. It should be 'Sam'.
Section C: Definitions
Q1
string — Text made of a sequence of characters (single letters, digits or symbols), written in quotes, like 'Sam' or '0412345678'. Phone numbers are strings.
Section D: Fill in the Blanks
Q1
Field: Phone Data type: Text
Q2
phone = "0412345678" print(phone)
Q3
print(len("0412345678"))
Q4
Initial: Character Name: String
Q5
print("04" + "12")
Section E: Spot the Error
Q1
C — A phone number is a string, so it must be in quotes: phone = "0412345678". Without quotes it is treated as a number and the leading 0 is lost.
Q2
A — The string is missing its closing quote. It should be mobile = "0412 345 678".
Q3
B — Text must be written inside quotes. Without them Bandicoot is read as a variable name. It should be word = "Bandicoot".
Q4
D — Strings are joined (concatenated) with +, not -. It should be full = first + space + last.
Q5
D — Quotes make "c" a string, so the letter c would be printed. To show the joined text "75" stored in the variable, use print(c).