Data types and constants

About this lesson: Data types and constants

In short

Every value has a data type: int (whole number), float (decimal), str (text) or bool (True/False). The type decides what you can do with it. Go through the values.

Data types and constants

What you'll explore

Data types: Number, text or True/False?
Every value has a data type: int (whole number), float (decimal), str (text) or bool (True/False). The type decides what you can do with it.
Choosing types: Data for a quiz
A quiz stores a name, a score and whether the answer was correct. Each needs the right type. Step through and watch the variables.
Constants: A name for a fixed value
A constant is a named value that stays the same while the program runs, like a minimum age. Python writes constants in capitals.
Check yourself: Pick the type
A running app stores how far you ran, such as 3.75 km.

Also in this lesson

  • Common mix-ups
  • Types at a glance
  • Using types and a constant
  • Type hunt

Words to know

data type
The kind of value: int, float, str or bool.
integer (int)
A whole number.
real (float)
A number with a decimal part.
string (str)
Text, written in quote marks.
Boolean (bool)
True or False.
constant
A named value that doesn't change while the program runs.

Sources

  • Python documentation: Built-in types
  • PEP 8: naming constants

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

← Decisions in code · Combining conditions in code →

All lessons in Term 3 · Computing · Age 12