A namespace is a group of presently defined emblematic names along with information about the object that each name references. You can suppose a namespace as a guide by which the keys are the object names and the values are the objects themselves. Each key-value brace maps a name to its matching object.
Global Namespace
The global namespace has any names defined at the position of the main program. When the main program body starts, Python develops the global namespace and it remains in actuality until the practitioner terminates.
The practitioner also develops a global namespace for any module that your program loads with the import statement.
Built-in Namespace
A built-in namespace has the names of built-in functions and objects. It's created while starting the python practitioner, exists as long as the practitioner runs, and is destroyed when we close the practitioner. It includes the names of built-in data types, exceptions, and functions like print () and input ().
Local namespace
A local namespace is defined for a class, a function, a circle, or any block of law. The names defined in a block of law or a function are local to it. The variable names can not be penetrated outside the block of law or the function in which they're defined. The local namespace is created when the block of law or the function starts executing and terminates when the function or the block of law terminates. The conception of the local namespace can be understood from the following illustration. -in namespace contains the names of built-in functions and objects. It's created while starting the python practitioner, exists as long as the practitioner runs, and is destroyed when we close the practitioner. It includes the names of built-in data types, exceptions, and functions like print () and input ().
A local namespace is defined for a class, a function, a circle, or any block of law. The names defined in a block of law or a function are local to it. The variable names can not be penetrated outside the block of law or the function in which they're defined. The local namespace is set up when the block of law or the function starts executing and terminates when the function or the block of law terminates. The conception of the local namespace can be understood from the following illustration.
myNum1 = 20
myNum2 = 20
def add(num1, num2):
temp = num1 + num2
return temp