in Python by
Q:
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.

Click here to read more about Python
Click here to read more about Insurance

Related questions

0 votes
asked May 17, 2020 in Python by SakshiSharma
0 votes
asked Jan 1 in Python by SakshiSharma
0 votes
asked Jun 28, 2020 in Python by Robindeniel
0 votes
asked Nov 16, 2019 in Python by rajeshsharma
0 votes
asked Aug 30, 2020 in Python by sharadyadav1986
...