Python’s built-in data types represent numbers, true-or-false values, sequences, text, binary data, sets, and key-value mappings. Choose among them by asking what the value represents, whether it needs to change, and whether you need positions, uniqueness, or key-based lookup. This guide covers the core built-ins; Python has other built-in types beyond this introductory inventory.
What are the data types in Python?
A type defines what kind of value an object represents and which operations make sense for it. Python’s core built-in types include int, float, complex, bool, list, tuple, range, str, bytes, bytearray, memoryview, set, frozenset, and dict. The Python Software Foundation’s Python 3.14.8 built-in types documentation describes these families and their behavior.
Four properties help distinguish them:
- Mutability: whether an object can be changed after it is created.
- Ordering and indexing: whether values form a sequence with positions that can be accessed by index.
- Hashability: whether a value can serve as a dictionary key or a set member. Immutable built-ins are not automatically hashable; their contents matter too.
- Purpose: the kind of information the type is designed to represent.
Numeric types: int, float, and complex
The Python documentation identifies three distinct numeric types: integers, floating-point numbers, and complex numbers. Python integers have unlimited precision in the language’s documented semantics. A float is a floating-point value, normally represented using the C double format. A complex value has real and imaginary floating-point components.
intrepresents whole numbers, such as42or-7.floatrepresents floating-point numbers, such as3.14.complexrepresents values with real and imaginary parts, such as2 + 3j.
decimal.Decimal and fractions.Fraction are useful numeric types in Python’s standard library, but they are not built-in numeric types.
Boolean values: bool
A Boolean represents a truth value and has exactly two values: True and False. The type bool is a subclass of int, so booleans can behave numerically like zero and one. The documentation discourages relying on that behavior without explicit conversion; use Boolean logic for conditions and convert deliberately when you need a number.
Sequences: list, tuple, and range
Sequences preserve positions and support indexing. Use a list when the collection should change, a tuple when its structure should stay fixed, and a range when you need a patterned sequence of integers.
List
A list is a mutable sequence. You can replace, add, or remove items, and access items by position. Lists are useful for collections that will be updated, such as a queue of tasks or a set of results gathered during a calculation.
Tuple
A tuple is an immutable sequence. Its elements cannot be replaced or removed after creation, making it suitable for a fixed group of values. The comma creates a tuple; parentheses are often used for clarity but are not what makes it one. For example, (x) is just x, while (x,) is a one-item tuple.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →A tuple can be used as a dictionary key or set member only if every value it contains is hashable. Immutability alone does not guarantee hashability.
Range
A range is an immutable sequence representing a pattern of integers, commonly used for iteration. It stores the pattern rather than a separate copy of every represented integer, so it uses a small fixed amount of memory relative to the sequence length.
Text and binary data: str and the bytes family
Use str for text and bytes-family types for binary sequences. The Python documentation states that textual data is handled with str objects, or strings.
str for text
A str represents text, such as a name, sentence, or message. It is an immutable sequence of text characters, so it supports sequence operations such as indexing and slicing.
bytes and bytearray for binary sequences
bytes represents an immutable binary sequence; bytearray represents a mutable one. These types are appropriate when working with encoded text, file contents, or other data that must be handled as bytes rather than as text characters.
Turning bytes into text requires decoding with a specified encoding. For example, use data.decode('utf-8') or str(data, 'utf-8') when UTF-8 is the correct encoding. str(data) by itself does not decode the bytes.
memoryview for buffer access
A memoryview provides access to data in a buffer without copying that data. It is useful when code needs to inspect or work with buffer-backed data while avoiding an additional copy.
Sets and mappings: uniqueness versus key-value lookup
Use a set to track distinct hashable values, and a dictionary to associate hashable keys with values. Neither is a sequence for positional access.
Recommended Free Tools
Best Value
set and frozenset
A set contains distinct hashable objects. It is mutable and useful for checking membership or removing duplicates. Sets do not preserve sequence-style positions or support indexing. A frozenset is an immutable set; it is hashable and can therefore be used as a dictionary key or as a member of another set.
Use set() to create an empty set. Empty braces, {}, create an empty dictionary instead.
dict
A dict is a mutable mapping from hashable keys to values. Use it when a value should be retrieved by a meaningful key, such as looking up a user’s settings by option name. Dictionary values can be arbitrary objects; keys must be hashable.
Keys that compare equal can refer to the same dictionary entry. For example, 1, 1.0, and True compare equal and can address the same key.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsWhich Python data type should you use?
| If you need… | Use | Why |
| A collection with positions that you will change | list |
Mutable sequence with indexing. |
| A fixed group of values in a particular order | tuple |
Immutable sequence; it can be hashable if all its contents are hashable. |
| A patterned sequence of integers | range |
Immutable integer sequence that stores a pattern rather than every value. |
| Lookup by a key | dict |
Maps hashable keys to values. |
| Distinct values or fast membership checks | set |
Stores unique hashable members without sequence indexing. |
| An immutable set that can itself be a key or set member | frozenset |
Immutable and hashable. |
| Human-readable text | str |
Python’s text type. |
| Mutable or immutable binary data | bytearray or bytes |
Choose mutable bytearray or immutable bytes. |
| Access to buffer data without copying | memoryview |
Exposes buffer data without making a copy. |
For examples of common sequence and mapping operations, see the Python Software Foundation’s Python 3.14.8 data structures tutorial.
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.




