Variables
Python variables don't need a declared type — you simply assign a value, and Python figures out the type automatically. A variable can even be reassigned to a value of a different type later, since Python is dynamically typed.
💡 Key insight
Even though you don't declare types, every value in Python still has a specific type underneath — check it anytime with type().
Syntax
syntax
variableName = valueExample
type() reveals the underlying type Python inferred for a value.
py
age = 20
price = 49.99
name = "CodeyHub"
print(name, age, price)
print(type(age))outputCodeyHub 20 49.99
<class 'int'>
Try it yourself
Copy this example into the Python compiler and run it — try changing a value and see what happens.
