Data Types
Python has several built-in data types.
Numbers
x = 42 # int
y = 3.14 # float
z = 2 + 3j # complex
Strings
name = "Alice"
greeting = f"Hello, {name}!"
multi = """
line one
line two
"""
Lists
fruits = ["apple", "banana", "cherry"]
fruits.append("date")
print(fruits[0]) # apple
print(fruits[-1]) # date
Dictionaries
person = {"name": "Alice", "age": 30}
print(person["name"]) # Alice
person["city"] = "NYC" # add key
Tuples
point = (10, 20) # immutable
x, y = point # unpacking
Sets
unique = {1, 2, 3, 2, 1}
print(unique) # {1, 2, 3}
Type checking
type(42) # <class 'int'>
isinstance(42, int) # True