Python Tutorial 21 --- "Scope, Global Variables and Global Keyword"
Python Tutorial 21 --- "Scope, Global Variables and Global Keyword" This Program or Tutorial is about "Scope, Global Variables and Global Keyword" DOC: What is Scope in Python? Scope refers to the coding area where a particular Python variable is accessible. Hence one cannot access any particular variable from anywhere from the code. We have studied about variables in previous lectures. Recall that a variable is a label for a location in memory. It holds a value. Not all variables are accessible, and not all variables exist for the same amount of time. Where the variables defined determines that is it accessible or not, and how long it will exist. Local vs. Global Variables Local Variable:- A variable that is declared inside a function or loop is called a local variable . In the case of functions, when we define a variable within a function, its scope lies within the function only. It is accessible from the point where it is defined until the end of the function...