GCSE · Computer Science · Eduqas · Spec C500QS
Using a variety of data types
You type 1, then 2. Your program prints 12. The fix works perfectly, until someone types the word four.
Computer Science · Data types
You typed 1 and 2. Why does it print 12?
Run the same program twice, on different inputs. Make your call before each answer appears.
Pick an input, then step through. At each marked line, call the result before it appears.
first = input("First number: ")second = input("Second number: ")print(first + second)total = int(first) + int(second)print(total)
Variables
Step 1. You type 1. input() hands it back as the string "1". The quote marks show it is text, not a number.
Ask of every value: what type is it right now, and what will + do to that type?
Computer Science · Choosing a type
Which type would you give each item?
Sort each item of data into the type that suits it best.
Still to sort
Integer (0)
Whole numbers.
Where the line is: No fractional part. Counts of things are usually integers.
Real (0)
Numbers with a fractional part (floating point).
Where the line is: If it can have a decimal part, such as pounds and pence, it is real.
Boolean (0)
Two states: true or false.
Where the line is: Use it when the only possible answers are yes or no.
String (0)
Text. It can hold letters, digits and symbols.
Where the line is: Digits you never calculate with belong here.
Char (0)
A single character, in pseudocode and other languages.
Where the line is: One character only. Python itself holds a single character as a string of length one.
Every item gets exactly one type. Ask what it holds, and what the program will do with it.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
Why the type of a value decides what your program can do with it.
What you need to know
- A data type is the kind of data a computer can store and the actions you can perform on it.
- An integer stores whole numbers. Real (floating point) numbers hold decimal numbers. A Boolean holds true or false.
- A string holds text, but it can also hold digits and symbols. Char is a single character.
- Choose a type from what the item holds and how it will be used. Digits you never calculate with, like a phone number, go in a string.
Have a goDev stores whether a pupil handed in their homework as an integer. Dev's friend says that is odd. Who is right, and what type fits better?
The friend. A Boolean fits better: true or false.
Choose the type from what the item holds. Handed in or not has two states, which is what a Boolean is for, not a count of whole numbers.
- A program needs to know the type to process data correctly. You can't do calculations with strings.
- input() returns a string, even if you type a number.
Have a goA user types 3.5 at an input() prompt. Before any casting, is the program holding a real number or a string?
A string: "3.5".
input() returns a string even when what you typed looks like a number. Casting comes later.
- Adding two strings joins them together. So an uncast 1 and 2 give 12, not 3.
- Casting changes a value's type. Use str() for a string, int() for an integer and float() for a real number.
Have a goYou hold the string "20" and want to add 5 to it. Which cast do you reach for?
int() (or float()), to turn it into a number first.
You can't do calculations with strings, so the value has to be cast to a number before the sum.
- To calculate with an input, cast it with int() or float() first. Float on 5 gives 5.0, which may not be what you wanted.
- Casting can still fail: type the word four and an error happens when the program runs, and it crashes.
The big picture
Every item of data has a data type, which decides what a program can store and do with it. input() always returns a string, so two uncast inputs are joined, cast inputs are added, and text that is not a number crashes the program when it is cast.
Key points
Worked example
Problem
A shop program asks for the price of one pencil, typed as 2.5 (pounds), and prints the cost of two pencils as "Cost: " followed by the cost. Make it work.
⚠ Watch out
Thinking a number typed at an input prompt reaches the program as a number. It does not: input() returns a string, so cast it with int() or float() first, and text that is not a number still crashes.
Memory hook
Before every +, ask: what type is each value right now? Strings join, numbers add, and input() always starts as a string.
Check yourself
A program prints a + b, where a and b both come from input(). A user types 6 and 9. What prints, and what change would print 15?
Flashcards
(13)What does a data type define?
What does an integer store?
What does a real (floating point) number hold?
What does a Boolean hold?
What can a string hold?
What is char short for, and what does it hold?
What is casting?
Which function converts a value to a string?
Which function converts a value to an integer?
Which function converts a value to a real number?
What type does input() return in Python?
What happens when + is used on two strings?
Why can a program still crash after you cast an input?
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 Eduqas GCSE Computer Science topics
- Presenting test outcomes with commentary
- Program a solution to requirements
- Refining code during development
- Selection in programs
- Sequence in programs
- String manipulation in code
- Subroutines with well-defined interfaces
- Typical, extreme and erroneous test data
- Understanding revised requirements
- Using testing outcomes to inform development
- Validation and verification routines in code
- Variables, operators, inputs, outputs and assignment
How this lesson was checked. This Eduqas GCSE Computer Science (specification C500QS)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 16 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.