Skip to main content
Python has several built-in data types that form the foundation of the language. These types are always available without importing any module.

Numeric Types

int - Integer

Integers have unlimited precision in Python.

float - Floating Point

Double precision floating point numbers.

complex - Complex Numbers

Complex numbers with real and imaginary parts.

bool - Boolean

Boolean values: True and False.

Sequence Types

str - String

Immutable sequence of Unicode characters.

list - List

Mutable sequence, typically used for homogeneous collections.

tuple - Tuple

Immutable sequence, typically used for heterogeneous collections.

range - Range

Immutable sequence of numbers.

Mapping Type

dict - Dictionary

Mutable mapping of keys to values.

Set Types

set - Set

Unordered collection of unique elements.

frozenset - Immutable Set

Immutable version of set.

Binary Sequence Types

bytes - Immutable Bytes

bytearray - Mutable Bytes

memoryview - Memory View

Provides access to internal data of objects without copying.

None Type

None - Null Value

Represents absence of a value.

Type Checking

Type Conversion

Common Type Operations

Length

Membership Testing

Iteration

Best Practices

Choose the right type:
  • Use list for ordered, mutable collections
  • Use tuple for immutable sequences
  • Use set for unique, unordered collections
  • Use dict for key-value mappings
Avoid mutable default arguments:

Type Hints

Python 3.5+ supports type hints for better code documentation:

Built-in Functions

Functions that operate on these types

collections

Specialized container types

typing

Type hints and annotations

itertools

Iterator tools