AI engineering glossary · Python core
What is variable scope?
Variable scope: The region of a program where a name is visible and can be used. Names created inside a function are local to it and vanish when it ends, while names at the top of a file are global.
Variable scope: an example
def f(): y = 5 makes y exist only inside f; print(y) outside raises NameError.
Related terms
More Python core terms
Where you learn it
Variable scope is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.