Skip to content
On this page

Data Structures

Lists:

Lists are ordered, mutable collections of elements.

python
# Lists
fruits = ['apple', 'banana', 'cherry']
numbers = [1, 2, 3, 4, 5]
mixed_list = [1, 'hello', True, 3.14]

Tuples:

Tuples are ordered, immutable collections of elements.

python
# Tuples
coordinates = (10, 20)
colors = ('red', 'green', 'blue')

Sets:

Sets are unordered, mutable collections of unique elements.

python
# Sets
numbers = {1, 2, 3, 4, 5}
fruits = {'apple', 'banana', 'cherry'}

Dictionaries:

Dictionaries are unordered collections of key-value pairs.

python
# Dictionaries
person = {'name': 'Alice', 'age': 30, 'is_student': True}
grades = {'math': 90, 'science': 85, 'history': 78}