Every value in Python has a type, which determines what operations make sense on it and how it behaves. Python groups its built-in types into a handful of families: numeric (int, float, complex), text (str), ordered sequences (list, tuple, range), key-value mappings (dict), unordered unique collections (set, frozenset), boolean (bool), and the special NoneType.
Unlike some languages, you never declare a variable's type up front — Python infers it entirely from the value you assign.
#how it works
1
Numeric types
int, float, complex — hold numbers of different kinds.
2
Text type
str — holds a sequence of characters.
3
Sequence types
list, tuple, range — hold ordered collections, accessed by position.
4
Mapping type
dict — holds key-value pairs, accessed by key rather than position.
5
Set types
set, frozenset — hold unordered collections with no duplicates.
6
Boolean type
bool — holds exactly two values, True and False.
7
NoneType
Holds a single value, None, representing the absence of a value.
#example
print(type(42))
print(type(3.14))
print(type("hello"))
print(type([1, 2, 3]))
print(type({"a": 1}))
print(type(True))
print(type(None))
Output
<class 'int'>
<class 'float'>
<class 'str'>
<class 'list'>
<class 'dict'>
<class 'bool'>
<class 'NoneType'>
1type() is a built-in function that returns an object’s type.
2Each call shows Python's type name wrapped in <class '...'> — that's simply how Python displays a type object when printed.
3bool shows up as its own distinct type, even though True and False behave like 1 and 0 in arithmetic — more on that in Booleans.
#use cases
Checking a variable's type with type() or isinstance() before performing an operation that assumes a specific type
Understanding error messages like TypeError: unsupported operand type(s), which almost always trace back to mixing incompatible types
Choosing the right built-in type up front — a list for an ordered collection you’ll change, a tuple for one you won’t
Reading function documentation, which specifies the types each argument expects
Practice Python interview questions
Every Python lesson maps to the matching interview topic, with answers written for current Python versions.
Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses →Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free →Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books →