← Back to Python Course Foundations
Python Variables
Learning Objectives
- Apply valid variable naming rules.
- Use dynamic typing and multiple assignment.
- Distinguish local and global scope.
Example
x, y = 10, 20
name = "Asha"
count = 0
def increment():
global count
count += 1
increment()
print(x, y, name, count)
Dry Run
x=10,y=20,name=Ashaincrement()updates globalcountto1
Common Mistakes
- Using keywords as variable names.
- Expecting local function variable to update global value without
global.
Practice
- Demonstrate type change in same variable.
- Create function with local and global variable comparison.