Python Lesson: Variables

1. What is a Variable?

A variable is a **name that stores data** in Python. You can use it to store numbers, text, or other data types.

x = 10          # Integer
name = "Alice"  # String
pi = 3.14       # Float
    

2. Variable Naming Rules

3. Assigning Values

a = 5
b = 10
c = a + b
print(c)  # Output: 15
    

4. Multiple Assignment

x, y, z = 1, 2, 3
print(x, y, z)  # Output: 1 2 3

a = b = c = 0
print(a, b, c)  # Output: 0 0 0
    

5. Dynamic Typing

Python allows you to change the type of a variable at any time.

var = 10
print(var)  # 10
var = "Hello"
print(var)  # Hello
    

6. Data Types Reminder

7. Ready for the Quiz?

Take the Variables Quiz