Python’s core data structures for storing and organizing information
Lists are ordered, changeable collections. They can store any type of data and can be modified after creation.
fruits = ["apple", "banana", "cherry"]
numbers = [1, 2, 3, 4]
mixed = ["hello", 42, True]
print(fruits[0]) # apple
print(fruits[-1]) # cherry
fruits[1] = "blueberry"
fruits.append("orange")
fruits.remove("apple")
numbers = [3, 1, 4, 2]
numbers.sort() # [1, 2, 3, 4]
numbers.reverse() # [4, 3, 2, 1]
Tuples are ordered but immutable collections. Once created, their values cannot be changed.
point = (10, 20)
colors = ("red", "green", "blue")
print(point[0]) # 10
Dictionaries store data as key‑value pairs. They are unordered, changeable, and extremely useful for structured data.
person = {
"name": "Alice",
"age": 30,
"city": "Budapest"
}
print(person["name"]) # Alice
print(person.get("age")) # 30
person["age"] = 31
person["job"] = "Developer"
del person["city"]
print(person.keys())
print(person.values())
print(person.items())
Now that you understand Python’s core data structures, you’re ready to learn how to control program flow using conditions in Lesson 6: Conditional Logic (if/elif/else).
← Back to Lesson Index