CBSE Class 12 Computer Science Question 39 of 101

Functions — Question 7

Back to all questions
7
Question

Question 7

What is scope? What is the scope-resolving rule of Python?

Answer

Scope refers to part(s) of program within which a name is legal and accessible. When we access a variable from within a program or function, Python follows name resolution rule, also known as LEGB rule. When Python encounters a name (variable or function), it first searches the local scope (L), then the enclosing scope (E), then the global scope (G), and finally the built-in scope (B).