Variables & Data Types in Python

From the Python cheat sheet · Setup & Basics · verified Jul 2026

Variables & Data Types

Python variables are dynamically typed — no declaration keyword needed.

python
# Variables (no declaration keyword)
name = "Alice"
age = 30
price = 19.99
is_active = True

# Check type
type(name)    # <class 'str'>

# Multiple assignment
x, y, z = 1, 2, 3
a = b = c = 0
💡 Python is dynamically typed — variables can change type at any time
⚡ Use x, y = y, x to swap values — no temp variable needed
📌 Falsy values: None, 0, 0.0, empty string, empty list/dict/set, False
🟢 Use isinstance() over type() for type checking — it supports inheritance
variablestypesbasics

More Python tasks

Back to the full Python cheat sheet