Every value in Python has a data type — it tells Python (and you) what kind of data you're working with, and what operations make sense on it. You can't divide a piece of text by 2, but you can divide a number by 2 — the data type is what makes that distinction. Python has several built-in data types covering numbers, text, and true/false logic, plus collection types for grouping values together.
Core Built-in Data Types
whole_number = 42 # int
decimal_number = 3.14 # float
text = "Hello, Python" # str
is_valid = True # bool
nothing = None # NoneType
print(type(whole_number))
print(type(decimal_number))
print(type(text))
print(type(is_valid))
print(type(nothing))
Output:
<class 'int'>
<class 'float'>
<class 'str'>
<class 'bool'>
<class 'NoneType'>
The built-in type() function is the easiest way to check what type a value is at any point in your code — extremely useful while debugging.
Numbers: int, float, and complex
Python has three numeric types. int represents whole numbers of any size (Python automatically handles very large integers without overflow). float represents decimal numbers. complex represents complex numbers with a real and imaginary part, written as 3 + 4j — rarely needed outside scientific computing, but good to know it exists.
big_number = 123456789012345678901234567890
print(type(big_number))
complex_number = 3 + 4j
print(complex_number, type(complex_number))
Output:
<class 'int'>
(3+4j) <class 'complex'>
Collection Types: list, tuple, set, dict
Beyond single values, Python has four built-in types for grouping multiple values together. Each has a different rule about ordering, duplicates, and whether it can be changed after creation:
my_list = [1, 2, 3] # ordered, changeable, allows duplicates
my_tuple = (1, 2, 3) # ordered, unchangeable, allows duplicates
my_set = {1, 2, 3} # unordered, no duplicates allowed
my_dict = {"a": 1, "b": 2} # key-value pairs
print(type(my_list), type(my_tuple), type(my_set), type(my_dict))
Output:
<class 'list'> <class 'tuple'> <class 'set'> <class 'dict'>
Each of these deserves its own deep dive, which this tutorial series covers separately — for now, just know they exist and are what Python reaches for whenever you need to store more than one value.
Mutable vs Immutable Types
A type is mutable if its value can be changed after creation, and immutable if it cannot. int, float, str, bool, and tuple are immutable — any "change" actually creates a brand-new value. list, set, and dict are mutable — you can modify them in place.
text = "hello"
# text[0] = "H" # this would raise a TypeError — strings are immutable
numbers = [1, 2, 3]
numbers[0] = 99 # this works fine — lists are mutable
print(numbers)
Output:
[99, 2, 3]
This distinction matters more as your programs grow, especially when passing data between functions. Once you're comfortable identifying Python's data types, the next useful skill is converting between them, covered in Python type conversion and type casting.
