🧩Scope
Also known as Variable Scope, Local Variable, Global Variable
Where in a program a name can be seen. Names in a function stay local.
Think of it like
Think of it like rooms in a house. A note left in the kitchen cannot be read from the bedroom.
Example
Lucy makes total inside a function, then tries to print it outside. Python says total is not defined.
Why it matters
Scope keeps big programs safe to change. Two functions can each use a name like count without clashing.
Definition
Example code
python
def f():
total = 5
f()
print(total)
# NameError: name 'total' is not defined