Python Basics: Variables & Data Types
Python · Beginner
Definition
Python variables are names bound to objects. Core types: int, float, str, bool, list, tuple, dict and set.
These types are used in every Python program.
Diagram
Flowchart
Example: Types in action
age = 20
name = 'Asha'
print(f'{name} is {age}', type(age).__name__)Output: Asha is 20 int
Key points
- Dynamically typed
- Lists are mutable, tuples are not
- Indentation defines blocks
Interview questions
List vs tuple?
Lists are mutable; tuples are immutable and hashable.
What does type() return?
The class of the object.