Skip to content
Kuza Ndoto Academy

Data Types

Beginner → IntermediateChapter 2 · Page 7 of 564 min readUpdated 15 Nov 2026

Every value in Python has a data type that decides what the value is and what you can do with it. You can add two numbers, but you can't sensibly divide a name by a phone number. Knowing the core types is the foundation for everything else in Python.

The core built-in types

TypeNameExamplesUsed for
intInteger21, -5, 0, 1000000Whole numbers: counts, ages, KES amounts without cents
floatFloating-point number3.14, -0.5, 2.0Numbers with a decimal point: measurements, averages
strString"Kisumu", 'A', ""Text of any length
boolBooleanTrue, FalseYes/no answers and conditions
NoneTypeNoneNone"No value yet" or "nothing here"

Use type() to check the type of any value:

print(type(42))
print(type(3.14))
print(type("Nairobi"))
print(type(True))
print(type(None))
<class 'int'> <class 'float'> <class 'str'> <class 'bool'> <class 'NoneType'>

Numbers: int and float

An int is a whole number with no decimal point. Python integers can be as large as your computer's memory allows. A float has a decimal point, even if the part after it is zero.

students = 45          # int
height = 1.72          # float
whole = 2.0            # still a float, because of the decimal point

print(type(whole))
print(students * 2)
print(height * 2)
<class 'float'> 90 3.44

There's also a complex type for numbers such as 3 + 4j, used in engineering and science. You won't need it in this series. Numbers get their own page: Numbers & Arithmetic.

Text: str

A string is a sequence of characters inside single or double quotes. Anything in quotes is text, even if it looks like a number.

print(42 * 2)
print("42" * 2)
84 4242

The first line multiplies a number. The second repeats a string twice, which is a very different result. Strings are covered in depth on the Strings page.

Yes or no: bool

A Boolean has only two possible values: True and False (always with a capital letter). Comparisons produce Booleans, and they drive every decision your program makes.

age = 17
is_adult = age >= 18

print(is_adult)
print(type(is_adult))
print(10 > 3)
False <class 'bool'> True
Note

Behind the scenes, bool is a special kind of int: True behaves like 1 and False like 0. So True + True gives 2. This is occasionally handy for counting, but don't rely on it to make code clever.

Nothing: None

None is Python's way of saying "there is no value here". It is useful as a placeholder, for example before a user has entered their phone number. It is not the same as 0, False or an empty string; it is its own special value.

phone = None
print(phone)
print(phone is None)
None True

To check for None, use is None rather than == None. You'll see why on the Operators page.

Checking types with isinstance()

isinstance(value, type) answers "is this value of this type?" with True or False. It is the usual way to check types inside programs.

print(isinstance(7, int))
print(isinstance(7.0, int))
print(isinstance("7", str))
print(isinstance(True, int))
True False True True

The last result surprises many people: because bool is a kind of int, True counts as an integer too.

Collection types (a preview)

Python also has types that hold many values at once. Each has its own page in the Data Structures chapter.

TypeExampleKey feature
list["maize", "beans"]Ordered and changeable
tuple(-1.29, 36.82)Ordered and unchangeable
set{1, 2, 3}Unique items, no order
dict{"name": "Amina"}Key–value pairs

Types are also either mutable (can be changed after creation, like lists and dictionaries) or immutable (can't be changed, like ints, floats, strings and tuples). This distinction matters more as your programs grow.

Built-in types Numeric Text Boolean None Collections intfloatcomplex str bool NoneType listtuplesetdict
Figure 1. The built-in types grouped by family. Every value you create belongs to exactly one of these types, which type() reports.
Common mistake

Mixing text and numbers without converting them. "Age: " + 21 raises a TypeError because Python won't guess whether you want text or maths. Convert first with str(21), or pass both to print() separated by a comma. See Type Conversion.

Common mistake

Writing true, false or none in lowercase. Python only recognises True, False and None with capital first letters; the lowercase versions cause a NameError.

Key points

  • The core types are int, float, str, bool and NoneType.
  • A value's type decides what you can do with it; "42" and 42 behave differently.
  • Use type() to inspect a value and isinstance() to test it.
  • None means "no value"; check it with is None.
  • Lists, tuples, sets and dictionaries hold collections of values.
Up next · Python BasicsNumbers & ArithmeticIntegers, floats and the maths operators.
→

Tip: use the ← and → keys to move between pages.