Python provides four built-in and highly versatile data structures: List, Tuple, Dictionary, and Set. These structures are used to store collections of data and support efficient operations such as insertion, deletion, searching, and iteration. Together, they form the foundation of Python programming and are used in almost every application—from data analysis to web development.
A List is an ordered, mutable (changeable) collection of items. It can store elements of different data types.
Ordered (maintains insertion order)
Mutable
Allows duplicate values
Indexed (supports indexing & slicing)
| Operation | Example | Output |
|---|---|---|
| Append | fruits.append("grape") | Adds item |
| Insert | fruits.insert(1,"kiwi") | Adds at index |
| Remove | fruits.remove("apple") | Deletes |
| Slicing | fruits[1:3] | Sublist |
Dynamic data
Data that needs frequent updates
A Tuple is an ordered, immutable collection of items.
Ordered
Immutable (values cannot be changed)
Allows duplicates
Faster than lists
Data protection (immutable)
Useful in fixed data (coordinates, constant values)
A Dictionary stores data as key–value pairs. It is an unordered, mutable, and highly optimized data structure.
Stores data in key:value format
Keys must be unique
Mutable
Fast lookup
| Operation | Example |
|---|---|
| Access | student["name"] |
| Add | student["grade"] = "A" |
| Update | student["age"] = 22 |
| Delete | del student["course"] |
| Get keys | student.keys() |
JSON data
Data modeling
Key-value storage systems
A Set is an unordered collection of unique items.
No duplicate values
Unordered
Mutable
Supports mathematical set operations
Removing duplicates
Membership testing (very fast)
Mathematical operations
| Feature | List | Tuple | Dictionary | Set |
|---|---|---|---|---|
| Ordered | ✔ | ✔ | (Python 3.7+) ✔ | ❌ |
| Mutable | ✔ | ❌ | ✔ | ✔ |
| Allows Duplicates | ✔ | ✔ | Keys ❌, Values ✔ | ❌ |
| Indexing | ✔ | ✔ | Key-based | ❌ |
| Use Case | Dynamic data | Fixed data | Key-value mapping | Unique items/set ops |
Python’s built-in data structures—Lists, Tuples, Dictionaries, Sets—form the backbone of efficient data handling.
Lists are ideal for dynamic and frequently updated data.
Tuples are perfect when data must remain constant.
Dictionaries provide fast, structured storage using key-value pairs.
Sets are best for uniqueness and mathematical operations.
A good understanding of these structures is essential for writing optimized and readable Python programs.
Take quizzes related to this topic and see where you stand!
Start Quiz Now