Python Data Structures Explorer
Learn about Python's fundamental data structures: Lists, Tuples, Sets, and Dictionaries with interactive examples.
Lists & Tuples
Lists are mutable ordered collections, while tuples are immutable ordered collections.
List Example:
my_list = [1, 2, "ba", 4, 0.5]
Tuple Example:
today = (1, 2, "ba", 4, 0.5)
Sets & Dictionaries
Sets are unordered unique collections, while dictionaries store key-value pairs.
Set Example:
s = {2, 3, 5, 11}
Dictionary Example:
house = {"Phòng ngủ": 5, "Thành phố": "Hà Nội"}
Control Flow
Conditional Statements
name = "NeuTech"
if name.lower() == "neutech":
print("That's my name too!")
elif name.lower() == "santa":
print("That's a funny name.")
else:
print(f"Hello {name}!")
Loops
# For loop
for n in [1, 3, -1, 5]:
print(n)
# While loop
n = 5
while n > 0:
print(n)
n -= 1