Notes / Python / Variables

Variables in Python — Revision Notes

A quick-reference cheat sheet: definition, syntax, example, common mistakes and an interview tip.

beginner 📖 2 min revision

Definition

📌 Variables Python variables don't need a declared type — you simply assign a value, and Python figures out the type automatically.

Syntax

syntax
variableName = value

Example

py
age = 20
price = 49.99
name = "CodeyHub"

print(name, age, price)
print(type(age))

Output

outputCodeyHub 20 49.99 <class 'int'>

Important Points

Common Mistakes

Interview Tip

🎯 Before your interview Be ready to explain "dynamic typing" in one sentence: the type is checked at runtime based on the value, not declared ahead of time by the programmer.
Back to notes Read full lesson →