Skip to main content
Albero Academy

Data Types

Python's core built-in types — numbers, strings, booleans and None — and how to inspect a value's type.

Fundamentals12 min

Every value in Python has a type that determines what you can do with it. You don't declare types, but knowing them is essential — half of all beginner bugs are a value being a different type than you assumed.

The core built-in types

TypeExampleUse for
int42, -7Whole numbers
float3.14, 7.5Decimal numbers
str"hello"Text
boolTrue, FalseTruth values
NoneTypeNoneAbsence of a value
values and their types
count = 42 # int
price = 7.5 # float
name = "Albero" # str
active = True # bool
result = None # NoneType — a deliberate "no value"

Strings

Strings are text in quotes (single or double). They support indexing, slicing and many methods:

working with text
s = "Python"
len(s) # 6
s[0] # 'P' (indexing)
s[-1] # 'n' (from the end)
s[0:3] # 'Pyt' (slicing)
s.upper() # 'PYTHON'
"is fun".split() # ['is', 'fun']
f"{s} rocks" # f-string interpolation

Checking types

type() and isinstance()
type(42) # <class 'int'>
isinstance(7.5, float) # True
isinstance(42, (int, float)) # True — any of these types

Key takeaways

  1. 01Core types: int, float, str, bool, and None (NoneType).
  2. 02Strings support indexing, slicing and rich methods; f-strings interpolate values.
  3. 03None represents a deliberate absence of a value.
  4. 04Check types with isinstance(x, T), the idiomatic choice over type(x) == T.

Finished this chapter?

Mark it complete to track your progress through Python.