Python data types define what kind of value a variable holds and what operations you can perform on it. Every value in Python belongs to exactly one type, and that type determines everything from how much memory the value uses to which methods are available on it. When you write x = 42, Python automatically knows that 42 is an integer, not a string or a list, and it gives you access to all the arithmetic operations that integers support. Understanding the full set of built-in types that Python provides is the step that moves you from writing simple scripts to building programs that handle real data efficiently.
If you have worked through the earlier articles on Python variables and object references, you already know that every variable points to an object in memory and that the object's type governs its behavior. This article surveys every major built-in type so you can recognize them, understand what they store, and know which one to reach for in any situation. Each type gets its own deep-dive article later in this section, starting with the integer data type.
The type categories at a glance
Python organizes its built-in types into a small number of categories that group similar kinds of data together. Numeric types handle numbers of different kinds. Sequence types handle ordered collections that you can index by position. Mapping types connect keys to values for fast lookups. Set types store unique items and support mathematical set operations. A few special types cover truth values and the concept of nothing.
Here is a summary of the major built-in types and what each one stores:
| Category | Types | What it stores | Mutable? |
|---|---|---|---|
| Numeric | int, float, complex | Whole numbers, decimals, imaginary numbers | No |
| Boolean | bool | True or False | No |
| Null | NoneType | The absence of a value | N/A (singleton) |
| Text | str | Unicode characters | No |
| Sequence | list, tuple, range | Ordered collections | list: yes, tuple: no |
| Mapping | dict | Key-value pairs | Yes |
| Set | set, frozenset | Unique items | set: yes, frozenset: no |
Every type in this table is built into the Python language itself. You do not need to import anything to use integers, strings, lists, or dictionaries. They are always available, and they form the vocabulary that every Python program speaks.
Numeric types: integers, floats, and complex numbers
Integers represent whole numbers without a decimal point, both positive and negative, with no fixed maximum size. Python's integers grow to accommodate whatever value you need, limited only by available memory. You will use integers for counting, indexing, looping, and any calculation that deals with discrete quantities.
Floats represent numbers with fractional parts using the IEEE 754 double-precision format that your computer's processor understands natively. This means floats are fast but have limited precision: roughly 15 to 17 significant decimal digits. You will use floats for measurements, percentages, scientific values, and any quantity that is not a whole number. The article on float data type covers floating-point precision and common pitfalls in detail.
Complex numbers, written with a j suffix like 3 + 4j, represent quantities with real and imaginary parts. They are less common in beginner programs but essential in scientific computing, signal processing, and electrical engineering. Python supports them natively with no import required.
Boolean type: True and False
The boolean type has exactly two values: True and False. Booleans are technically a subclass of integers in Python, which means True behaves like 1 and False behaves like 0 in arithmetic contexts. You will use booleans most often as the result of comparisons and as conditions in if-statements and loops.
Any Python value can be tested for truthiness in a boolean context. Empty collections, zero numbers, None, and empty strings evaluate to False. Non-empty collections, non-zero numbers, and non-empty strings evaluate to True. This truthiness model is the foundation of conditional logic in Python, and the article on the boolean data type covers it thoroughly.
The None type: representing nothing
None is Python's singleton null value. It represents the intentional absence of any other value and is the only instance of its type, NoneType. Functions that do not explicitly return a value return None by default. Variables that have not yet been assigned a meaningful value are often initialized to None as a placeholder.
None has a special status in Python that makes it different from other falsy values like 0 or an empty string. Checking for None with the is operator rather than double-equals is the idiomatic Python pattern because there is only ever one None object, and identity comparison is both faster and immune to being overridden by custom equality methods. The dedicated article on the None data type explains when and why to use None versus other sentinel values.
Sequence types: strings, lists, and tuples
Sequence types store ordered collections of items that you can access by position using an index inside square brackets. Python indexing starts at zero, so the first item is at index 0, and negative indices count backward from the end.
Strings store Unicode text and are immutable. Once created, a string's contents cannot be changed. Operations like concatenation or replacement always produce a new string object rather than modifying the original. Strings support slicing, searching, case conversion, splitting, joining, and dozens of other methods that make text processing a core strength of Python.
Lists store ordered, mutable sequences of any type of object, and a single list can hold integers, strings, other lists, and custom objects all at once. You can add items, remove items, reorder items, and change individual elements at any index. Lists are the workhorse collection type that you will use constantly.
Tuples store ordered, immutable sequences. Once created, a tuple's contents and length are fixed. This immutability makes tuples suitable as dictionary keys and as lightweight records where the structure should not change. Tuples are also the mechanism behind Python's multiple assignment feature.
Mapping and set types: dictionaries and sets
Dictionaries store key-value pairs and provide near-instant lookups by key. Each key must be unique and hashable, which means immutable types like strings, numbers, and tuples can be keys, but lists and other dictionaries cannot. Dictionaries are the foundation of nearly every data-handling Python program because they let you model real-world relationships directly.
Sets store unordered collections of unique, hashable items. They automatically eliminate duplicates and support mathematical operations like union, intersection, and difference. Sets are the right choice when you need to track unique values or test membership quickly without caring about order. A frozen set is an immutable version of a set that can be used as a dictionary key.
How Python determines types
Python is dynamically typed, which means you never write the type name when creating a variable. The interpreter determines the type from the value at runtime. The built-in type function tells you the type of any object, and the isinstance function lets you check whether a value belongs to a specific type or any of several types at once.
Type conversion between compatible types is straightforward. The functions int, float, str, bool, list, tuple, and set each convert values to the corresponding type when the conversion makes sense. Converting a float like 3.7 to an integer truncates the decimal portion and yields 3. Understanding when conversions happen implicitly and when you must call them explicitly is covered in the later articles on type conversion and type casting.
Rune AI
Key Insights
- Python is dynamically typed; you do not declare types, but every value has one.
- Numeric types include int, float, and complex for whole numbers, decimals, and imaginary numbers.
- The boolean type is a subclass of int with only two values: True and False.
- None is a singleton type representing the absence of a value.
- Sequence types include str (text), list (ordered mutable), and tuple (ordered immutable).
- Dict is a key-value mapping, and set is an unordered collection of unique items.
Frequently Asked Questions
How many built-in data types does Python have?
Do I need to declare data types in Python?
What is the difference between mutable and immutable data types?
Conclusion
Python's built-in data types cover the vast majority of programming needs without requiring any imports. Understanding what each type stores, whether it is mutable, and how to convert between types gives you the foundation for every Python program you will write.
More in this topic
Create and Assign Variables in Python
Learn every way to create and assign variables in Python, from basic single assignment to expressions, type hints, and practical patterns beginners use every day.
Python Variable Naming Rules
Learn Python's variable naming rules, including allowed characters, reserved keywords, PEP 8 conventions, and how to choose names that make your code readable.
Python Variables Explained
Understand what Python variables are, how they store and reference data, and why Python's variable model is different from other programming languages.