GCSE · Computer Science · OCR · Spec J277
Data type: Character and string
Type 5, then 5, into a program that adds two numbers. It prints 55. Nothing is broken: Python did exactly what you told it. So what did you tell it?
Computer Science · Data types
Two fives make fifty-five
Six lines of Python. The user types 5, then 5. Step through and keep your eye on the trace table: the quotes tell you what each value really is.
Before you press Next: the user types 5, then 5. What do you think the last line prints?
1 x = 5 + 52 print(x)3 a = input("First number: ")4 b = input("Second number: ")5 total = a + b6 print(total)
| x | a | b | total |
|---|---|---|---|
| 10 |
Output
Step 1: No quotes anywhere: 5 and 5 are numbers here, so + adds them. x holds 10. No surprises yet.
Quotes in the trace table mean the value is stored as a string (text). No quotes means a number.
Computer Science · Data types
Char, string or not text at all?
Pick a value, then choose where it belongs.
Still to sort
Char: a single character (0)
Exactly one character inside the quotes. A letter, a digit, a symbol and even a space all count.
Where the line is: A char is really a string that is just one character long. So "a" is a char, but "ab" is a string.
String: text of several characters (0)
Text in quotes. Letters, digits, spaces and symbols are all allowed.
Where the line is: Digits in quotes are still text. "2026" is a string, not a number.
Not text: a number (0)
No quotes. Python treats it as a number, so + would add it.
Eight values. Count what's inside the quotes, and check whether there are quotes at all.
Predict, then check
Look at exactly what's inside the quotes, spaces included.
first = "Priya" and last = "Shah". What does print(first + last) show?
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
Type a number into a program and it feels like a number. To Python it might just be text. By the end you'll know why, and how to stay in control of it.
What you need to know
- Python uses data types to store and process information correctly.
- A string holds data as text. You write it inside quotes, like "hello".
- Strings aren't just letters: they can hold numbers, characters and symbols. "£4.99" is text.
- Char is short for character. A char is a single string character, such as "a".
Have a goYour mate insists "ok" must be a char, because it's such a tiny word. Do you agree?
No. "ok" is a string.
A char is one single character, and "ok" has two. Being short doesn't make something a char; only having exactly one character does.
- input always returns a string, even when the user types a number.
- Add two strings with + and they're concatenated, which means joined together end to end.
Have a goPredict: what does "10" + "1" give?
"101"
Both values are strings, so + joins them end to end. It doesn't add them to make 11: that only happens with numbers.
- Concatenation adds nothing extra, not even a space. If you want a space, join one in.
- The str function converts a value to a string: str(42) gives "42".
Have a goTry it in your head: what does str(3) + "D" give?
"3D"
str turns the number 3 into the string "3", then + joins the two strings. Without str, Python would refuse to join the number to the text.
- Python won't join a number straight onto a string with +. Convert the number with str first.
The big picture
Python uses data types to store and process information correctly. A string holds data as text, written in quotes, and it can hold numbers, characters and symbols as well as letters. A char (short for character) is a single string character, such as "a". The input function always returns a string, even when the user types a number. Adding two strings with + concatenates them: it joins them end to end, so "5" + "5" gives "55". The str function converts a value to a string, which is how you join a number onto a message.
Key points
Worked example
Problem
A program runs these three lines, and the user types 2026: year = input("Year: ") age = 15 print("In " + year + " I am " + str(age)) What data type is each value, and exactly what does the last line print?
⚠ Watch out
Treating a typed number as a number. input returns a string, so if a program reads 3 and 4 with input and adds them with +, it concatenates them and gets "34", not 7.
Memory hook
Quotes mean text. Two fives make fifty-five when they're strings.
Check yourself
Cover the page. Explain why "9" is a char but "99" is not. Then say what "9" + "9" gives, and what str(9) gives.
Flashcards
(10)Why does Python use data types?
What is a string?
What does char stand for, and what is it?
Is "2026" a number or a string?
What data type does input return when the user types a number?
What does concatenate mean?
Does concatenation add a space between the strings?
Which function converts a value to a string?
Why does "Age: " + 15 cause an error, and how do you fix it?
Is a space a character?
Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.
Learning with Lightbulb is opening soon
You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.
Keep me postedMore OCR GCSE Computer Science topics
How this lesson was checked. This OCR GCSE Computer Science (specification J277)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 3 November 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.