Python data types describe the values objects can represent and the operations they support. For example, 42 is an int, 3.14 is a float, "hello" is a str, [1, 2] is a list, and {"name": "Ada"} is a dict. Use type(value) to inspect an object, or isinstance(value, int) to check whether it is an integer or an instance of an int subclass.
What a Python data type describes
Python represents data as objects. As the Python 3.14.8 data model puts it, “Every object has an identity, a type and a value.” An object’s type determines what values it can represent and which operations it supports.
A variable name is a reference to an object, not a box with a permanently declared type. A name can refer to objects of different types at different points in a program:
item = 42 # item refers to an int object
item = "hello" # now it refers to a str object
The objects have types; the name item is not locked to one type.
#1 Best Overall
How to inspect an object’s type
Call type() to see an object’s concrete type:
type(7) # <class 'int'>
type(7.0) # <class 'float'>
type("7") # <class 'str'>
type([7]) # <class 'list'>
Although 7, 7.0, and "7" may look related, they are an integer, a floating-point number, and text. Their types affect which operations make sense and how Python handles them.
When checking whether an object belongs to a type family, prefer isinstance():
isinstance(42, int) # True
Unlike a direct comparison such as type(value) is int, isinstance(value, int) also returns true for instances of subclasses of int.
Common built-in types at a glance
This table focuses on what each type represents and the behaviors that help distinguish it. “Ordered” means the type has a defined sequence or iteration order; only sequence types support positional indexing.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →| Type | What it represents | Mutable? | Order and indexing | Natural use |
|---|---|---|---|---|
int |
Whole numbers with unlimited precision | No | Not applicable | Counts and integer arithmetic |
float |
Floating-point numbers | No | Not applicable | Approximate real-number calculations |
complex |
Numbers with real and imaginary parts | No | Not applicable | Complex-number calculations |
bool |
Truth values: True and False |
No | Not applicable | Conditions and logical results |
str |
Text as a sequence of Unicode code points | No | Ordered and indexable | Text processing |
bytes |
Immutable binary data | No | Ordered and indexable | Binary data that should not change |
bytearray |
Mutable binary data | Yes | Ordered and indexable | Binary data that needs in-place changes |
list |
A collection of items | Yes | Ordered and indexable | A sequence that may change |
tuple |
A collection of items | No | Ordered and indexable | A fixed sequence |
range |
An arithmetic progression of integers | No | Ordered and indexable | Representing a sequence of integers, commonly for iteration |
set |
A collection of unique, hashable elements | Yes | No positional indexing | Membership checks, deduplication, and set operations |
frozenset |
An immutable collection of unique, hashable elements | No | No positional indexing | Set operations when an immutable, hashable set is needed |
dict |
Key-to-value mappings | Yes | Preserves insertion order; access values by key | Looking up values by key |
NoneType (the value None) |
The singleton value commonly used to indicate absence | No | Not applicable | Representing “no value” where appropriate |
The built-in type descriptions and behaviors are documented in the Python 3.14.8 built-in types reference and the data model reference.
How to choose a collection type
For collections, choose according to how you will use the data: whether its order matters, whether you need indexing, whether items can change, and whether you need uniqueness or key-based lookup.
Rank #2
Use a list for an ordered collection that can change
A list keeps items in sequence, supports indexing, and allows in-place changes:
colors = ["red", "blue"]
colors.append("green")
colors[0] = "purple"
After these operations, colors is ["purple", "blue", "green"].
Recommended Free Tools
Use a tuple for a fixed sequence
A tuple is ordered and indexable, but its items cannot be reassigned:
point = (3, 5)
# point[0] = 4 # raises TypeError
“Immutable” means the tuple’s item references cannot be changed. If a tuple contains a mutable object, that contained object may still be mutable.
Use a set for unique membership
A set stores unique elements and supports membership and mathematical set operations. It does not provide positional indexing, so use a sequence when you need to retrieve an element by its position.
numbers = {1, 2, 2, 3}
print(numbers) # {1, 2, 3}
print(2 in numbers) # True
Elements must be hashable. A mutable list, for example, cannot be an element of a set.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Use a dictionary for key-to-value lookup
A dictionary maps keys to values and preserves insertion order. Retrieve a value by its key rather than by position:
person = {"name": "Ada", "role": "programmer"}
print(person["name"]) # Ada
Keys must be hashable. Lists and dictionaries cannot be keys because they are mutable. A dictionary’s insertion order is useful when iterating, but it does not make the mapping a position-indexed sequence.
Mutability: whether an object can change
Mutable objects can be changed after creation; immutable objects cannot. Lists, dictionaries, sets, and byte arrays are mutable. Tuples, strings, bytes, integers, and floating-point numbers are immutable.
This distinction matters when multiple names refer to the same object. Changing a mutable object through one name is visible through the other; an operation that appears to change an immutable value instead produces a different object or value.
first = [1, 2]
second = first
first.append(3)
print(second) # [1, 2, 3]
Here, first and second refer to the same list. By contrast, operations on immutable strings do not alter the original string in place.
Numbers, booleans, and truth testing
Numeric types
int represents integers with unlimited precision. float represents floating-point values, which are not a promise of exact decimal arithmetic. complex represents values with real and imaginary parts. For specialized numeric work, Python’s standard library also provides Decimal and Fraction.
Booleans are truth values, not ordinary numbers
bool has exactly two values, True and False. It is a subclass of int, but that relationship is usually not a reason to use booleans as numbers in application code. Write conditions to express truth rather than relying on arithmetic behavior such as treating True as one.
Truth testing is not the same as checking for a boolean
Python treats False, None, numeric zero, and empty sequences or collections as false in a Boolean context. Other objects are generally true unless their type defines a different truth value.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →That does not make None, False, and an empty string interchangeable. For example, use value is None when you need to check specifically for the absence marker, rather than relying on if not value, which also matches other false values.
Also, and and or do not necessarily return a Boolean. They return one of their operands, which can be useful for selecting values but may surprise code that expects a strict True or False.
Text, binary data, and None
Strings represent text
A str is a sequence of Unicode code points, not a special single-character type. It is immutable, but supports sequence operations such as indexing and slicing:
word = "hello"
print(word[0]) # h
Bytes and bytearray represent binary data
Use bytes for immutable binary data and bytearray when the binary data needs to be changed in place. They are distinct from str: text and encoded bytes are different kinds of values.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Best Value
None represents absence
None is a singleton value commonly used to indicate that a value is absent. Its type is NoneType. It is not the same value as False or "", even though each is false in a Boolean context.
Converting between types safely
Constructors such as int() can convert some values, but conversion is not a complete validation strategy for untrusted input.
int("7") # 7
Text that does not represent a valid integer raises ValueError, and some conversions discard information. For example, converting a floating-point value to an integer drops its fractional part. Decide what inputs your program accepts and handle conversion errors explicitly; a successful conversion alone does not establish that the input meets every application requirement.
Type annotations help tools, not runtime enforcement
Annotations communicate intended types to readers and can help type checkers, IDEs, and linters find mistakes. They do not, by default, make Python reject a value of the wrong type when a function runs.
def greet(name: str) -> str:
return "Hello, " + name
The annotation says that name is expected to be a string and that the function is expected to return a string. Python does not automatically enforce those expectations at runtime. The Python 3.14.8 typing documentation explains the role of annotations and notes that runtime enforcement is not provided by default.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




