Python Tutorial 0/52 lessons ~6 min read Lesson 6
Variables & Assignment
In Python, variables are names bound to objects, not boxes that hold values.
Course progress0%
Focus
8 guided sections
Practice signal
Examples included
Career prep
Foundation builder
Introduction
In Python, variables are names bound to objects, not boxes that hold values. You don't declare types — Python infers them at runtime.
Understanding the topic
Core concepts to understand:
x = 42binds the name x to an int object.- Reassignment changes the binding, not the object.
- Multiple assignment:
a, b = 1, 2. - Constants by convention:
UPPER_CASE.
Syntax reference
Visual flow / code:
python
name = "Alice"age = 30is_admin = True# Multi / swapa, b = 1, 2a, b = b, a # swap# Type hints (optional but recommended)score: int = 100
Execution workflow
1Variables & Assignment Workflow
1 / 4Step 1
x = 42 binds the name x to an int object.
Apply this step while implementing variables & assignment in real code.
Real-world use
Type hints, added in Python 3.5, are now standard in production code — they enable mypy, IDE autocomplete, and self-documenting APIs.
Best practices
- Use snake_case for variables.
- Add type hints on public functions.
- Avoid 1-letter names except in loops.
Hands-on exercise
Interview preparation — practice these questions:
- Is Python statically or dynamically typed?
- What's the difference between
=and==? - What are type hints?
Summary
In summary: Names → objects, not boxes. Type hints = production hygiene.
Ready to mark this lesson complete?Track your journey across the entire course.