How Python stores and handles different kinds of data
Variables are names that store values in memory. In Python, you create a variable simply by assigning a value to a name:
name = "Alice"
age = 25
height = 1.72
Python uses dynamic typing, meaning you don’t need to declare a type before assigning a value.
Python includes several built‑in data types used in everyday programming:
message = "Hello, world!"
count = 42
price = 19.99
is_active = True
result = None
You can check the type of any variable using type():
print(type(name)) # <class 'str'>
print(type(age)) # <class 'int'>
print(type(height)) # <class 'float'>
Python allows converting between types when possible:
age_str = "30"
age_num = int(age_str) # "30" → 30
pi = 3.14
pi_str = str(pi) # 3.14 → "3.14"
flag = bool(1) # 1 → True
All input from input() is a string, so conversion is often needed:
age = input("Enter your age: ")
age = int(age)
print(age + 5)
Now that you understand variables and data types, you’re ready to explore how Python handles text in Lesson 4: Working with Strings.
← Back to Lesson Index