First steps in Python

Python is a textual programming language used by beginners and by professionals. You type the instructions, and spelling and punctuation matter.

Practise this lesson free (6 questions)

More tools

Output with print

print shows something on the screen.
print("Hello, world!")
Text in quotes is a string. Numbers do not need quotes: print(5 + 2) shows 7.

Variables

A variable is a named box that stores a value. = puts a value into it.
name = "Sam"
age = 12
print("Hello", name)
print(age + 1)
Output:
Hello Sam
13
Variable names cannot contain spaces or start with a number. Use names that explain the data, such as score.

Input and data types

input reads what the user types. It always gives a string.
name = input("Your name? ")
To do maths with typed numbers, convert with int() for whole numbers:
age = int(input("Age? "))
Watch out: "3" + "4" joins strings to make 34, but 3 + 4 is 7.
Worked example

What does this program print?
x = 5
x = x * 2
x = x - 3
print(x)

  1. x starts as 5.
  2. x = 5 * 2 = 10.
  3. x = 10 - 3 = 7.

Answer: 7

Key idea

print shows output, = stores a value in a variable, input reads text from the user and int() turns it into a whole number. Strings in quotes join together; numbers add.

Key words
AND
A Boolean operator that gives True (1) only when both inputs are True.
Output
Information sent out from a computer, for example to a screen, speaker or printer.
Variable
A named store in memory that holds a value, which can change while the program runs.
Input
Data put into a computer, for example from a keyboard, mouse, microphone or sensor.
String
A data type for text, written in quotation marks, such as "hello".
NOT
A Boolean operator that flips its input: True becomes False and False becomes True.

All KS3 Computing key terms and definitions โ†’

Common mistakes
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. What does this program print?
    x = 7
    x = x + 5
    print(x)

    Show the answer

    Answer: 12

    x starts at 7, then becomes 7 + 5 = 12.

  2. What does this program print?
    a = "5"
    b = "2"
    print(a + b)

    Show the answer

    Answer: 52

    a and b are strings, so + joins them: 52.

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, 27 October 2026. Last updated 2 October 2026. Spotted a mistake? Tell us and we will fix it.

Related lessons