Python data types tell you what a value is and which operations it supports. For everyday code, choose a list for an ordered sequence you may change, a tuple for a sequence whose slots should stay fixed, a set for unique values, and a dictionary for looking up values by key.
What is a data type in Python?
Python represents data as objects. Each object has an identity, a type, and a value; its type determines the operations it supports. For example, you can add numbers, join strings, append to a list, or retrieve a dictionary value by key. These are common built-in types, not a complete list of every type available in Python.
As an Amazon Associate I earn from qualifying purchases.
The examples below use the built-in types documented in Python 3.14.7’s built-in types reference.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Common Python types at a glance
| Type | Example | What it represents |
|---|---|---|
int |
12 |
An integer; Python integers have unlimited precision. |
float |
3.5 |
A floating-point number. |
complex |
2 + 3j |
A number with real and imaginary components. |
bool |
True |
A Boolean value: True or False. bool is a subtype of int. |
str |
"Ada" |
Immutable text. Python has no separate character type; a one-code-point string is still a str. |
list |
[8, 9, 10] |
An ordered, mutable sequence that can contain repeated values and values of different types. |
tuple |
(2, 5) |
An ordered, immutable sequence. |
range |
range(5) |
A sequence representing an arithmetic progression, rather than a stored list of all its values. |
bytes |
b"ABC" |
Immutable binary data. |
bytearray |
bytearray(b"ABC") |
Mutable binary data. |
set |
{"python", "beginner"} |
An unordered collection of unique elements. |
frozenset |
frozenset({"python", "beginner"}) |
An immutable set. |
dict |
{"name": "Ada"} |
A mutable mapping of unique keys to values. |
How do you check a value’s type?
Use type(value) to see the value’s type:
name = "Ada"
print(type(name)) # <class 'str'>
When checking whether an object belongs to a type or one of its subclasses, Python’s isinstance(value, SomeType) is generally the more useful check:
#1 Best Overall
if isinstance(name, str):
print("name is text")
Which Python collection should you use?
| Collection | Organization and duplicates | Can contents change? | Typical access |
|---|---|---|---|
list |
Ordered sequence; repeats are allowed. | Yes. | Index, slice, or iteration. |
tuple |
Ordered sequence; repeats are allowed. | No, its slots cannot be reassigned. | Index, slice, or iteration. |
set |
Unique elements; no sequence order or indexing. | Yes. | Membership tests and set operations. |
dict |
Unique keys associated with values; insertion order is preserved. | Yes. | Lookup by key. |
This practical distinction follows the Python data structures tutorial: choose based on how you need to organize and access data.
Use a list for a sequence you will change
Lists keep items in order and allow updates, additions, and removals. They can hold mixed types, though lists of one kind of value are common.
scores = [8, 9, 10]
scores.append(11)
print(scores) # [8, 9, 10, 11]
Use a tuple when the sequence’s slots should stay fixed
A tuple is ordered like a list but immutable: you cannot reassign one of its slots after creation.
Rank #2
point = (2, 5)
# point[0] = 3 # Raises TypeError
Immutability applies to the tuple’s references, not automatically to every object inside it. If a tuple contains a list, that list can still change:
items = ([1, 2], "label")
items[0].append(3)
print(items) # ([1, 2, 3], 'label')
Use a set for uniqueness and membership
A set removes duplicate elements and supports membership tests and operations such as union, intersection, difference, and symmetric difference. Sets are unordered and do not support indexing.
tags = {"python", "beginner", "python"}
print(tags) # Contains one "python" element
print("beginner" in tags) # True
languages = {"python", "ruby"}
print(tags & languages) # Intersection
Use set() to create an empty set. Curly braces by themselves create an empty dictionary instead:
empty_set = set()
empty_dict = {}
Use a dictionary for key-to-value lookup
A dictionary maps unique keys to values. Retrieve a value using its key, not a numeric sequence position. Current Python dictionaries preserve insertion order, but their purpose is key-based mapping.
profile = {"name": "Ada", "active": True}
print(profile["name"]) # Ada
Dictionary keys must be hashable, so they can be used consistently as keys. Lists and dictionaries are mutable and cannot serve as dictionary keys. Numeric keys that compare equal, such as 1 and 1.0, refer to the same dictionary entry.
What does mutable or immutable mean?
A mutable object can be changed after it is created; an immutable object cannot. This matters when two variables refer to the same object: changing a mutable object through one reference is visible through the other.
scores = [8, 9]
alias = scores
scores.append(10)
print(alias) # [8, 9, 10]
Lists and dictionaries are mutable. Strings and numbers are immutable, as are tuples themselves. Trying to assign a character in a string raises TypeError:
name = "Ada"
# name[0] = "E" # Raises TypeError
A tuple’s immutability prevents changing its slots, but—as shown above—a mutable object stored in a slot can still be modified. Python’s data model documentation explains the distinction between objects, types, values, and mutability.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsNumbers, truth values, and absence
Numeric types
Python’s built-in numeric types are int, float, and complex. Integers have unlimited precision. Floats are floating-point values, and complex numbers have real and imaginary components.
Best Value
bool is a subtype of int. True and False are Boolean values, although they also participate in the integer type relationship.
Truthiness
Objects can be tested in conditions. By default an object is true unless its class defines false behavior through __bool__() or a zero-length result from __len__(). Empty strings and collections are false.
if []:
print("not printed")
if "hello":
print("this runs")
None
None is a distinct built-in singleton commonly used to represent the absence of a value. It is not the same as False, 0, or an empty string.
Binary data and additional built-ins
For file, encoding, or network work, Python also provides binary-data types. bytes is immutable, bytearray is mutable, and memoryview provides a view over binary data. These are useful when working with bytes rather than ordinary text; the built-in types reference describes their behavior.
For more practice with these everyday values and collections, the official Python tutorial’s informal introduction includes practical examples.
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.




