0 votes
in Python by
What are the global and local variables in Python?

1 Answer

0 votes
by

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.

Related questions

0 votes
asked Jun 11, 2020 in Python by Robindeniel
0 votes
asked Jan 11 in C Plus Plus by GeorgeBell
...