TN Online TestSamacheer Kalvi practice

Scoping - Formula Sheet

Share this chapter: Telegram

LEGB Scope Resolution Hierarchy

The LEGB rule determines the search priority order for resolving variable references:

PriorityScope TypeDescriptionExample / Location
1 (Highest)Local (L)Variables defined inside the current function or method.Inside local function block
2Enclosed (E)Variables defined within any enclosing outer functions (nested functions).Outer function of a nested function block
3Global (G)Variables defined at the top level of the program module.Top-level script outside all functions
4 (Lowest)Built-in (B)Pre-loaded system names and functions imported from libraries.Built-in modules and keywords

Class Member Access Modifier Rules

This table summarizes access rules for class members across standard object-oriented languages compared with Python:

ModifierC++ and Java SyntaxPython Emulation ConventionAccess Permissions
Publicpublic keywordStandard variable name (e.g., member)Accessible from anywhere inside or outside the class.
Protectedprotected keywordSingle underscore prefix (e.g., _member)Accessible within the class and its inherited sub-classes.
Privateprivate keywordDouble underscore prefix (e.g., __member)Accessible strictly within the class itself. Denied outside.
Solved MCQs → Practice test →

More for this chapter

Book Back Questions10 textbook MCQs · solved Additional MCQs15 extra MCQs · solved Practice TestInteractive · instant score Book Back TestTest yourself on the textbook set Additional MCQ TestTest yourself on the extra set Study NotesConcepts & methods

More chapters in Computer Science

View all
1 Function 2 Data Abstraction 4 Algorithmic Strategies 5 Python -Variables and Operators 6 Control Structures 7 Python functions 8 Strings and String manipulation 9 Lists, Tuples, Sets and Dictionary 10 Python Classes and objects 11 Database Concepts 12 Structured Query Language (SQL) 13 Python and CSV files 14 Importing C++ programs in Python. 15 Data manipulation through SQL 16 Data visualization using pyplot: line chart, pie chart and bar chart