Global Variables in Python: The variables that are declared outside the function are called global variables. These variables can be accessed or invoked by any function in the program.
Example:
1
2
3
4
def v() :
print g
g = "welcome to madanswer"
v()
Output:
1
Welcome to madanswer
Local Variables in Python: The variables that are declared inside a function are called local variables. These type of variables can be accessed only inside the function.