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.

Practise this lesson free (6 questions)

More tools

Data types

Python has no separate character type: a character is a string of length 1.
TypeHoldsPython example
IntegerWhole numbersscore = 42
Real (float)Numbers with a decimal partprice = 3.75
BooleanTrue or Falsefinished = False
CharacterA single letter, digit or symbolgrade = "A"
StringText: a sequence of charactersname = "Priya"

Input and output

input() shows a prompt and always returns a string.
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

Assignment stores a value in a variable: score = 0.
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.
Worked example

The user types Sam and 14 for the program above. What is output?

  1. name = "Sam", age = int("14") = 14
  2. print("Hello", name) gives Hello Sam
  3. age + 1 = 15

Answer: Hello Sam / Next year you will be 15

Key idea

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.

Key words
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 โ†’

Quick check

Try two quick questions

See if it has sunk in. Answers are marked straight away.

Extra practice

2 more questions

Try each one, then tap to check.

  1. Which data type should store a person's age in whole years?

    1. Real (float)
    2. Boolean
    3. Character
    4. Integer
    Show the answer

    Answer: Integer

    Whole numbers use integer.

  2. Which data type is best for a single letter grade such as 'B'?

    1. Boolean
    2. Integer
    3. Character (or string)
    4. 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.

Video for this lesson coming soon. Subscribe on YouTube

Sources and references

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? โ†’

Related lessons