What are the rules for a local and global variable in python?



What are the rules for a local and global variable in python?..

Answer / Rajni Pandey

A global variable is accessible within the function in which it's defined and from outside that function. A local variable, on the other hand, can only be accessed within its own function or nested function. To modify the scope of a variable, use the 'global' keyword for global variables inside functions.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Python Interview Questions

What are key features of python?

1 Answers  


How is unit test done in python?

1 Answers  


Explain me database connection in python flask?

1 Answers  


What are the use of sets in python?

1 Answers  


Is elif a keyword in python?

1 Answers  


In the above project, were you alone or were you in group of developers? If so, how many?

1 Answers  


What is a dictionary in python programming?

1 Answers  


How to call an external command in python?

1 Answers  


What is reuests module will do?

1 Answers  


How would you perform unit-testing on your python code?

1 Answers  


What does input () do in python?

1 Answers  


What does ‘#’ symbol do in python?

1 Answers  


Categories