Variables in Python
Variables are named containers for storing data values. In Python, you create a variable simply by assigning a value to a name – no need to declare the type beforehand.
Python is dynamically typed, meaning the type is determined at runtime and can change.
Creating Variables – Assignment
Use the equals sign = to assign a value.
Reassignment
You can change the value (and even type) of a variable anytime.
Naming Rules and Conventions
- Must start with a letter or underscore (_)
- Can contain letters, numbers, underscores
- Case-sensitive (age and Age are different)
- Use snake_case (lowercase with underscores) – Python convention
- Avoid Python keywords (like print, if, for)
Multiple Assignment
Assign multiple variables in one line.
Swapping Variables
Quick Quiz
We have reviewed and checked the materials, but errors may still occur. The content is provided for educational purposes only, so use it at your own responsibility and verify with other sources if needed.
✨ Ask Lara — your AI study partner
Unlock personalized learning support. Lara can explain lessons, summarize topics, and answer your study questions — available from the Go plan and above.
Lara helps you learn faster — exclusive to ReadyTools Go, Plus, and Max members.

