Every value in Python belongs to a specific built-in data type that defines what operations you can perform on it. Knowing your data types prevents runtime errors like trying to add a number directly to text.
Python groups its core types into numeric, text, sequence, mapping, set, boolean, and binary categories. You can inspect any object's type at runtime with type() or verify inheritance with isinstance().
| Category | Type Names | Mutable? | Example |
|---|---|---|---|
| Text | str |
No | "hello" |
| Numeric | int, float, complex |
No | 42, 3.14 |
| Sequence | list, tuple, range |
list only |
[1, 2], (1, 2) |
| Mapping | dict |
Yes | {"id": 1} |
| Set | set, frozenset |
set only |
{1, 2, 3} |
| Boolean | bool |
No | True, False |
| Empty | NoneType |
No | None |
When your function accepts flexible input, prefer isinstance() over type(x) == ... because isinstance() handles subclasses properly.
order_price = 49.95
tags = ["python", "backend"]
profile = {"name": "Tariq", "verified": True}
empty_result = None
print(isinstance(order_price, float)) # True
print(isinstance(tags, list)) # True
print(type(empty_result)) # <class 'NoneType'>
"Port: " + 8080 raises TypeError; convert with str(8080) or use an f-string f"Port: {8080}".None with ==: Always write if result is None: rather than if result == None:.Mutable objects like list and dict allow you to add, remove, or edit items in place. Immutable objects like int, str, and tuple create a new object whenever you change their value.
None mean in Python?None is Python's single null object representing the absence of a value, commonly returned by functions that have no explicit return statement.
Yes. bool is a subclass of int, so True equals 1 and False equals 0 in numeric contexts.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With
Experiment with the code from this lesson in our interactive playground.