---
title: "What are Python’s data structures?"  
description: "What are Python’s data structures?"  
author: "Anubhav Sharma"  
published: 2025-08-31  
updated: 2025-09-01  
canonical: https://www.mindstick.com/forum/161896/what-are-python-s-data-structures  
category: "python"  
tags: ["python", "python 2", "Python 3"]  
reading_time: 2 minutes  

---

# What are Python’s data structures?

**What are [Python](https://www.mindstick.com/articles/75378/simple-yet-useful-tips-when-using-python)’s [data structures](https://www.mindstick.com/blog/301312/data-structures-and-their-applications)? [explain](https://www.mindstick.com/forum/157854/what-is-system-debugging-explain-some-system-debugging-tools-used-in-modern-computer-systems) with example.**

## Replies

### Reply by Ravi Vishwakarma

Python provides several **built-in [data](https://www.mindstick.com/articles/13050/salesforce-aiming-to-dominate-predictive-analytics-with-data-science) structures**, and it also allows you to create custom ones. These are mainly divided into **primitive** and **non-primitive (collection)** data structures.

### 1. Primitive Data Structures

These are the most basic types:

- **int** → integers (`10`, `-3`)
- **float** → floating-point numbers (`3.14`, `-2.5`)
- **complex** → complex numbers (`3+4j`)
- **bool** → boolean values (`True`, `False`)
- **str** → strings (`"hello"`, `'Python'`)

### 2. Non-Primitive (Collections) Data Structures

These are used to store multiple values.

#### a. List

Ordered, mutable, allows duplicates.

## Example:

```python
fruits = ["apple", "banana", "cherry"]
```

#### b. Tuple

Ordered, immutable, allows duplicates.

## Example:

```python
coordinates = (10, 20)
```

#### c. Set

Unordered, mutable, does not allow duplicates.

## Example:

```python
unique_numbers = {1, 2, 3, 3}
# {1, 2, 3}
```

#### d. Dictionary (dict)

Unordered (insertion-ordered since Python 3.7), mutable, stores key–value pairs.

## Example:

```python
student = {"name": "Alice", "age": 20}
```

### 3. Specialized Data Structures (from `collections` module)

- **deque** → double-ended queue
- **Counter** → frequency counter
- **OrderedDict** → dict with ordering preserved (now built-in by default in Python 3.7+)
- **defaultdict** → dict with default values for missing keys
- **namedtuple** → tuple with named fields

### 4. User-Defined Data Structures

You can also implement:

- **Stack** (using list or `deque`)
- **Queue** (using `deque` or `queue.Queue`)
- **Linked List**
- **Tree**
- **Graph**
- **Hash Table** (dict is already a hash table internally)

**In short**:

- **Built-in collections** → `list`, `tuple`, `set`, `dict`
- **Extended collections** → `deque`, `Counter`, `defaultdict`, etc.
- **Custom** → stack, queue, linked list, trees, graphs.


---

Original Source: https://www.mindstick.com/forum/161896/what-are-python-s-data-structures

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
