Grokking Python Fundamentals
Ask Author
Back to course home

0% completed

Python - Variable scope
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Variable scope refers to the region of a program where a variable is accessible, while a namespace is a container for a set of identifiers (such as variable and function names) and manages ensuring that all names within it are unique. Python organizes these names into namespaces, and the scope of variables is determined by the location where the variable is defined.

Types of Scopes in Python

Python primarily has three types of scopes, which define the accessibility of variables. These scopes are:

  1. Local Scope
  2. Enclosing Scope
  3. Global Scope

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible