Python basics: data types, input and output
Every program takes input, processes it and gives output. Choosing the right data type makes the processing work.
Data types
| Type | Holds | Python example |
|---|---|---|
| Integer | Whole numbers | score = 42 |
| Real (float) | Numbers with a decimal part | price = 3.75 |
| Boolean | True or False | finished = False |
| Character | A single letter, digit or symbol | grade = "A" |
| String | Text: a sequence of characters | name = "Priya" |
Input and output
To do maths with it, convert it: int() for whole numbers, float() for decimals. str() turns a number into a string.
print() displays output. Separate items with commas.
name = input("Name: ")
age = int(input("Age: "))
print("Hello", name)
print("Next year you will be", age + 1)
Assignment and initialisation
Initialisation is the first assignment, giving a variable its starting value before it is used.
Python reads from right to left: in total = total + 5, it works out total + 5 first, then stores it.
The user types Sam and 14 for the program above. What is output?
- name = "Sam", age = int("14") = 14
- print("Hello", name) gives Hello Sam
- age + 1 = 15
Answer: Hello Sam / Next year you will be 15
Integer, real, Boolean, character and string are the basic types. input() returns a string, so use int() or float() before doing maths. Initialise variables before using them.
- Boolean
- A data type with only two values: True or False.
- String
- A sequence of characters.
- Assignment
- Storing a value in a variable, such as total = 0.
- Variable
- A named store whose value can change while the program runs.
- Initialisation
- Giving a variable its first value before it is used.
All GCSE and International GCSE Computer Science key terms and definitions โ
Try two quick questions
See if it has sunk in. Answers are marked straight away.
2 more questions
Try each one, then tap to check.
Which data type should store a person's age in whole years?
- Real (float)
- Boolean
- Character
- Integer
Show the answer
Answer: Integer
Whole numbers use integer.
Which data type is best for a single letter grade such as 'B'?
- Boolean
- Integer
- Character (or string)
- Real
Show the answer
Answer: Character (or string)
A single symbol is a character.
Check you have got it
Answer 6 quick questions with instant marking. If you get one wrong, GCSE-ready shows you why and gives you another go. It is free, and you do not need an account.
- Pearson Edexcel GCSE Computer Science (1CP2) specification, topic 6.2.1, 6.3.1, 6.3.2, 6.4.1
- Pearson Edexcel International GCSE Computer Science (4CP0) specification, topic 2.1.1, 2.3.1, 2.4.1
Facts checked against the sources below, 17 October 2026. Last updated 2 October 2026. Spotted a mistake? Tell us and we will fix it.
What do exam command words like explain and evaluate mean? โ