Scope in programming languages is the context in which a variable, function, or object is visible. Different languages have different ways of defining scope, but in general, variables and functions are visible within the scope they are defined in, as well as any parent scopes.
Python has a similar concept which can be most easily depicted by the diagram below.
There are 4 scopes, but the acronym has been reduced to three. The reason why is because the Built-In scope can be considered to be a subset of the global scope. The built-in scope includes only the built-in functions and modules, while the global scope includes all variables that are defined outside of a function or class.
Any variable defined within a function or class method is said to be in the local scope. Variables defined in the local scope are only accessible within the scope in which they were defined.
Any variable defined within a class is said to be in the encapsulated scope. Variables defined in the encapsulated scope are accessible only within the class in which they were defined.
Any variable defined outside of a function or class method is said to be in the global scope. Variables defined in the global scope are accessible from anywhere in the code.
In simple coding terms, in python, scope looks like this.