Input, variables and output

About this lesson: Input, variables and output

In short

A variable is a named place in memory that holds a value. The = sign means 'store', not 'equals'. Step through the program and watch the trace table fill in.

Input, variables and output

What you'll explore

Variables: Named boxes for values
A variable is a named place in memory that holds a value. The = sign means 'store', not 'equals'.
Input and output: Talk to the user
input() waits for the user to type, and always gives back text. int() turns that text into a whole number so you can do maths with it.
Data types: Every value has a type
Python's main types are integer (int), float, string (str) and Boolean (bool). The type decides what you can do with a value. Slide through all four.
Types matter: Same sign, different job
With numbers, + adds. With strings, + joins them together. Mixing the two causes an error. Predict each output before you tap.
A whole program: Input, process, output
This program asks for a room's length and width, works out the area and perimeter, and prints them with an f-string. Change the inputs and run it.
Check yourself: Predict the output
age = input("Age? ") The user types 12. Then the program runs print(age * 2).

Also in this lesson

  • Programs to read
  • Watch out for these
  • Writing good code in tests
  • How much memory does each type use?
  • More than the lesson
  • Stretch your brain
  • Code it yourself

Words to know

variable
A named location in memory that holds a value that can change.
constant
A named value that does not change while the program runs.
assignment
Storing a value in a variable with =.
input
Data given to a program, often typed by the user.
output
Data a program gives back, like printed text.
data type
The kind of data: integer, float, string or Boolean.
integer
A whole number.
float (real)
A number with a decimal part.
string
Text, written in quotes.
Boolean
True or False.
casting
Changing a value's type, like int("5").
concatenation
Joining strings together.

Sources

  • Python documentation: Built-in types; input(); f-strings
  • BBC Bitesize, GCSE Computer Science: Variables and data types
  • Computer History Museum: Ada Lovelace
  • Isaac Computer Science: Programming fundamentals

An interactive lesson with a live experiment: move the sliders, press the buttons and answer quick questions. 6 short steps and a 8-question quiz. Part of the Family plan. Written and checked by Shalo Lab. Last updated 10 November 2026.

← Hexadecimal and colour codes · Binary addition, overflow and shifts →

All lessons in Term 1 · Computing · Age 14