Master Basic Data Structures in Python with Simple Examples

Logan Jul 13, 2026

Data structures are fundamental to programming, serving as the backbone for organizing, processing, and storing data efficiently. Python, a powerful and versatile language, provides several built-in data structures to handle various sorts of data and operations. Let's delve into the world of Python's basic data structures.

Data structure in python
Data structure in python

Python's basic data structures can be categorized into two types: mutable and immutable. Immutable data structures cannot change once they are created, while mutable ones can be modified. Now, let's explore the key mutable and immutable data structures in Python.

a diagram with the words data structures in python
a diagram with the words data structures in python

Immutable Data Structures

Immutable data structures include numbers, strings, tuples, and ranges. These are readonly and have a fixed size.

Python Data Structures Cheat Sheet for Beginners (Lists, Tuples, Sets & Dictionaries)
Python Data Structures Cheat Sheet for Beginners (Lists, Tuples, Sets & Dictionaries)

The `int` and `float` data types store whole numbers and decimal numbers, respectively. Strings are sequences of characters enclosed in quotes. Tuples are ordered collections of items separated by commas and enclosed in parentheses. Lastly, ranges generate a sequence of numbers within a specified range.

Numbers

the four basic python data structures are shown in this screenshoter's guide
the four basic python data structures are shown in this screenshoter's guide

Python supports both integer and floating-point numbers, with no explicit declaration of type required. Here's an example: ```python num_int = 10 num_float = 3.14 print(num_int, num_float) ```

Strings

Strings can be defined using single, double, or triple quotes. They can be indexed, sliced, and concatenated. Consider this example: ```python str1 = "Hello" str2 = "World" print(str1 + str2) # Outputs: HelloWorld ```

Python Data Structures Cheat Sheet ✨
Python Data Structures Cheat Sheet ✨

Mutable Data Structures

Mutable data structures include lists, dictionaries, and sets. These can be changed after they're created and have a variable size.

Lists are ordered collections of items enclosed in square brackets, allowing duplicate elements and indexing. Dictionaries store data values in key:value pairs, designated by curly braces. Sets are unordered collections of unique items, defined by curly braces or the `set()` function.

Data Structure in Python #database #javascripts #projects #iot #programminglife #sql #programmerl...
Data Structure in Python #database #javascripts #projects #iot #programminglife #sql #programmerl...

Lists

Lists are versatile and can contain various data types. Here's an example of creating and manipulating a list: ```python list1 = [1, 2, 3, 'a', 'b', 'c'] list1[0] = 'one' print(list1) # Outputs: ['one', 2, 3, 'a', 'b', 'c'] ```

Data Structure in Python!!
Data Structure in Python!!
the cover of collection data types in python, with an image of numbers and symbols
the cover of collection data types in python, with an image of numbers and symbols
DSA in Python for Beginners: Complete Visual Guide
DSA in Python for Beginners: Complete Visual Guide
Data Structures
Data Structures
Python Complete Visual Guide for Beginners 🐍
Python Complete Visual Guide for Beginners 🐍
Data Structures in Python
Data Structures in Python
Data Structures in Python 💻
Data Structures in Python 💻
Python Data Types Explained Visually | Beginner Python Guide
Python Data Types Explained Visually | Beginner Python Guide
Data Structures
Data Structures
a diagram that shows the data structures in python
a diagram that shows the data structures in python
Ordered Vs Unordered Data Structures in Python
Ordered Vs Unordered Data Structures in Python
Python data types cheat sheet
Python data types cheat sheet
Python simplified for you!
Python simplified for you!
an image of a computer screen with the text, 12 essential ways to utilize python's data structure
an image of a computer screen with the text, 12 essential ways to utilize python's data structure
Python Learning Path for Beginners 2026 🚀
Python Learning Path for Beginners 2026 🚀
Python Data Structures for Beginners – Lists, Tuples, Sets & Dictionaries Explained
Python Data Structures for Beginners – Lists, Tuples, Sets & Dictionaries Explained
a book with an image of a page containing different types of words and numbers on it
a book with an image of a page containing different types of words and numbers on it
an image of a screen with text on it that reads, 7 essential ways to utilize python's data structure
an image of a screen with text on it that reads, 7 essential ways to utilize python's data structure
a diagram with the words data structure in it
a diagram with the words data structure in it
Coding For Beginners Python - Data Structures - Arrays
Coding For Beginners Python - Data Structures - Arrays

Dictionaries

Dictionaries enable quick data retrieval and are perfect for mapping keys to values. Here's an example: ```python dict1 = {'a': 1, 'b': 2, 'c': 3} print(dict1['b']) # Outputs: 2 ```

Different data structures in Python cater to varying needs, offering a flexible toolkit for managing and manipulating data. Understanding and effectively using these structures will enhance your Python skills and boost your coding efficiency.