📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials Python from Zero Variables and Types

Variables and Types

5 min read Quiz at the end
Python uses dynamic typing — no need to declare variable types. Variables are created on assignment: name = 'Alice'. Types include int, float, str, bool, and None. Use type() to check and isinstance() for type testing.

Variables and Data Types

name    = "Alice"    # str
age     = 25        # int
height  = 5.7       # float
is_active = True    # bool

# Type checking
print(type(name))   # <class 'str'>

# Dynamic typing
x = 10
x = "now a string"  # perfectly valid
Topic Quiz · 5 questions

Test your understanding before moving on

1. Which is a valid Python variable name?
💡 _count is valid — variable names can start with underscore but not digits or hyphens.
2. What type is True in Python?
💡 True and False are Python booleans (which are a subclass of int).
3. How do you check a variable's type?
💡 type(variable) returns the type of a Python variable.
4. What does None represent?
💡 None is Python's null value — represents the absence of a value.
5. Can a variable change type in Python?
💡 Python is dynamically typed — a variable can be reassigned to any type.