[go: up one dir, main page]

0% found this document useful (0 votes)
6 views6 pages

Level 014

Uploaded by

RaJu Bhai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views6 pages

Level 014

Uploaded by

RaJu Bhai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

#!

python3
"Working in The Scope of Global Scope(Program Level)"
import os
os.system("cls")
print("\n----------------GLOBAL SCOPE BEGINS HERE-----------------", end = "\n")

def outerFunction() :
"Working in The Scope of Outer Function(Enclosed Scope)"
print("\n----------------ENCLOSE SCOPE BEGINS HERE-----------------", end =
"\n")
print("\nAssigning The Variable in Enclosed Scope(outerFunction)", end = "\
n")
outerVariable = 10
def innerFunction() :
"Working in The Scope of Inner Function(Local Scope)"
print("\n----------------LOCAL SCOPE BEGINS HERE-----------------", end
= "\n")
print("\nAccessing The Variable in Local Scope(innerFunction) Belonging
To Enclosed Scope(outerFunction)", end = "\n")
print("\nThe Outer Function Variable Value is : ", outerVariable, end =
"\n")
print("\n----------------LOCAL SCOPE ENDS HERE-----------------", end =
"\n")

print("\nCalling The innerFunction() From Enclosed Scope(outerFunction)", end


= "\n")
innerFunction()
print("\ninnerFunction() Has Returned Back To Enclosed Scope(outerFunction)",
end = "\n")
print("\n----------------ENCLOSE SCOPE ENDS HERE-----------------", end = "\
n")

print("\nCalling The outerFunction() From Global Scope(Program Level)", end = "\n")


outerFunction()
print("\nouterFunction() Has Returned Back To Global Scope(Program Level)", end =
"\n")
print("\n----------------GLOBAL SCOPE ENDS HERE-----------------", end = "\n")#!
python3
"Working in The Scope of Global Scope(Program Level)"
import os
os.system("cls")
print("\n----------------GLOBAL SCOPE BEGINS HERE-----------------", end = "\n")

def outerFunction() :
"Working in The Scope of Outer Function(Enclosed Scope)"
print("\n----------------ENCLOSE SCOPE BEGINS HERE-----------------", end =
"\n")
print("\nAssigning The Variable in Enclosed Scope(outerFunction)", end = "\
n")
outerVariable = 10
def innerFunction() :
"Working in The Scope of Inner Function(Local Scope)"
print("\n----------------LOCAL SCOPE BEGINS HERE-----------------", end
= "\n")
print("\nAccessing The Variable in Local Scope(innerFunction) Belonging
To Enclosed Scope(outerFunction)", end = "\n")
print("\nThe Outer Function Variable Value is : ", outerVariable, end =
"\n")
print("\n----------------LOCAL SCOPE ENDS HERE-----------------", end =
"\n")

print("\nCalling The innerFunction() From Enclosed Scope(outerFunction)", end


= "\n")
innerFunction()
print("\ninnerFunction() Has Returned Back To Enclosed Scope(outerFunction)",
end = "\n")
print("\n----------------ENCLOSE SCOPE ENDS HERE-----------------", end = "\
n")

print("\nCalling The outerFunction() From Global Scope(Program Level)", end = "\n")


outerFunction()
print("\nouterFunction() Has Returned Back To Global Scope(Program Level)", end =
"\n")
print("\nCalling The innerFunction() From Global Scope(Program Level) Which is
Already Enclosed", end = "\n")
print("\nRaises An Error As Enclosed Functions OR Names Cannot Be Referenced At
Global Level", end = "\n")
innerFunction()
print("\n----------------GLOBAL SCOPE ENDS HERE-----------------", end = "\n")#!
python3
"Working in The Scope of Global Scope(Program Level)"
import os
os.system("cls")
print("\n----------------GLOBAL SCOPE BEGINS HERE-----------------", end = "\n")

def outerFunction() :
"Working in The Scope of Outer Function(Enclosed Scope)"
print("\n----------------ENCLOSE SCOPE BEGINS HERE-----------------", end =
"\n")
print("\nAssigning The Variable in Enclosed Scope(outerFunction)", end = "\
n")
outerVariable = 10
print("\n----------------ENCLOSE SCOPE ENDS HERE-----------------", end = "\
n")

print("\nPrinting The Reference Address of The outerFunction() From Global


Scope(Program Level)", end = "\n")
print("\nThe Reference Address of The Outer Function is : ", outerFunction, end =
"\n")
print("\nouterFunction() Has Returned Back To Global Scope(Program Level)", end =
"\n")
print("\n----------------GLOBAL SCOPE ENDS HERE-----------------", end = "\n")#!
python3
"Working in The Scope of Global Scope(Program Level)"
import os
os.system("cls")
print("\n----------------GLOBAL SCOPE BEGINS HERE-----------------", end = "\n")

def outerFunction() :
"Working in The Scope of Outer Function(Enclosed Scope)"
print("\n----------------ENCLOSE SCOPE BEGINS HERE-----------------", end =
"\n")
print("\nAssigning The Variable in Enclosed Scope(outerFunction)", end = "\
n")
outerVariable = 10
print("\n----------------ENCLOSE SCOPE ENDS HERE-----------------", end = "\
n")
print("\nAssigning The Reference Address of The outerFunction() To Another
Variable", end = "\n")
refOuterFunction = outerFunction
print("\nPrinting The Reference Address of The outerFunction()'s Reference Variable
From Global Scope(Program Level)", end = "\n")
print("\nThe Reference Address of The Outer Function From Reference Variable is :
", refOuterFunction, end = "\n")
print("\nPrinting The Reference Address of The outerFunction() From Global
Scope(Program Level)", end = "\n")
print("\nThe Reference Address of The Outer Function is : ", outerFunction, end =
"\n")
print("\nouterFunction() Has Returned Back To Global Scope(Program Level)", end =
"\n")
print("\n----------------GLOBAL SCOPE ENDS HERE-----------------", end = "\n")#!
python3
"Working in The Scope of Global Scope(Program Level)"
import os
os.system("cls")
print("\n----------------GLOBAL SCOPE BEGINS HERE-----------------", end = "\n")

def outerFunction() :
"Working in The Scope of Outer Function(Enclosed Scope)"
print("\n----------------ENCLOSE SCOPE BEGINS HERE-----------------", end =
"\n")
print("\nAssigning The Variable in Enclosed Scope(outerFunction)", end = "\
n")
outerVariable = 10
def innerFunction() :
"Working in The Scope of Inner Function(Local Scope)"
print("\n----------------LOCAL SCOPE BEGINS HERE-----------------", end
= "\n")
print("\nAccessing The Variable in Local Scope(innerFunction) Belonging
To Enclosed Scope(outerFunction)", end = "\n")
print("\nThe Outer Function Variable Value is : ", outerVariable, end =
"\n")
print("\nReturning The innerFunction() Through Return Statement at
Local Scope(innerFunction)", end = "\n")
print("\n----------------LOCAL SCOPE ENDS HERE-----------------", end =
"\n")
return innerFunction()

print("\n----------------ENCLOSE SCOPE ENDS HERE-----------------", end = "\


n")

print("\nAssigning The outerFunction() Call To Another Variable", end = "\n")


returnValueOuterFunction = outerFunction()
print("\nPrinting The Return Value of The Outer Function (returnValueOuterFunction)
: ", returnValueOuterFunction, end = "\n")
print("\nouterFunction() Has Returned Back To Global Scope(Program Level)", end =
"\n")
print("\n----------------GLOBAL SCOPE ENDS HERE-----------------", end = "\n")#!
python3
"Working in The Scope of Global Scope(Program Level)"
import os
os.system("cls")
print("\n----------------GLOBAL SCOPE BEGINS HERE-----------------", end = "\n")

def outerFunction() :
"Working in The Scope of Outer Function(Enclosed Scope)"
print("\n----------------ENCLOSE SCOPE BEGINS HERE-----------------", end =
"\n")
print("\nAssigning The Variable in Enclosed Scope(outerFunction)", end = "\
n")
outerVariable = 10
def innerFunction() :
"Working in The Scope of Inner Function(Local Scope)"
print("\n----------------LOCAL SCOPE BEGINS HERE-----------------", end
= "\n")
print("\nAssigning The Variable in Local Scope(innerFunction)", end =
"\n")
innerVariable = 20
print("\nAdding The Local Scope Variable With Enclose Scope Variable",
end = "\n")
innerResult = outerVariable + innerVariable
print("\nReturning The innerFunction() Through Return Statement at
Local Scope(innerFunction)", end = "\n")
print("\n----------------LOCAL SCOPE ENDS HERE-----------------", end =
"\n")
print("\n----------------ENCLOSE SCOPE ENDS HERE-----------------", end
= "\n")
return innerResult

print("\nCalling The Inner Function innerFunction() in The Return Statement


of The Outer Function outerFunction()", end = "\n")
print("\nThis Will Make The Outer Function Return Statement To Wait Till The
Inner Function Does Not Returns", end = "\n")
return innerFunction()

print("\nAssigning The outerFunction() Call To Another Variable", end = "\n")


returnValueOuterFunction = outerFunction()
print("\nPrinting The Return Value of The Outer Function (returnValueOuterFunction)
: ", returnValueOuterFunction, end = "\n")
print("\nouterFunction() Has Returned Back To Global Scope(Program Level)", end =
"\n")
print("\n----------------GLOBAL SCOPE ENDS HERE-----------------", end = "\n")#!
python3
"Working in The Scope of Global Scope(Program Level)"
import os
os.system("cls")
print("\n----------------GLOBAL SCOPE BEGINS HERE-----------------", end = "\n")

def outerFunction() :
"Working in The Scope of Outer Function(Enclosed Scope)"
print("\n----------------ENCLOSE SCOPE BEGINS HERE-----------------", end =
"\n")
print("\nAssigning The Variable in Enclosed Scope(outerFunction)", end = "\
n")
outerVariable = 10
def innerFunction() :
"Working in The Scope of Inner Function(Local Scope)"
print("\n----------------LOCAL SCOPE BEGINS HERE-----------------", end
= "\n")
print("\nAssigning The Variable in Local Scope(innerFunction)", end =
"\n")
innerVariable = 20
print("\nAdding The Local Scope Variable With Enclose Scope Variable",
end = "\n")
innerResult = outerVariable + innerVariable
print("\nReturning The innerFunction() Through Return Statement at
Local Scope(innerFunction)", end = "\n")
print("\n----------------LOCAL SCOPE ENDS HERE-----------------", end =
"\n")
print("\n----------------ENCLOSE SCOPE ENDS HERE-----------------", end
= "\n")
return innerResult

print("\nCalling The Inner Function innerFunction() in The Return Statement


of The Outer Function outerFunction()", end = "\n")
print("\nThis Will Make The Outer Function Return Statement To Wait Till The
Inner Function Does Not Returns", end = "\n")
return innerFunction

print("\nAssigning The outerFunction() Call To Another Variable", end = "\n")


returnValueOuterFunction = outerFunction()
print("\nPrinting The Return Value of The Outer Function (returnValueOuterFunction)
: ", returnValueOuterFunction, end = "\n")
print("\nouterFunction() Has Returned Back To Global Scope(Program Level)", end =
"\n")
print("\n----------------GLOBAL SCOPE ENDS HERE-----------------", end = "\n")#!
python3
"Working in The Scope of Global Scope(Program Level)"
import os
os.system("cls")
print("\n----------------GLOBAL SCOPE BEGINS HERE-----------------", end = "\n")

def outerFunction() :
"Working in The Scope of Outer Function(Enclosed Scope)"
print("\n----------------ENCLOSE SCOPE BEGINS HERE-----------------", end =
"\n")
print("\nAssigning The Variable in Enclosed Scope(outerFunction)", end = "\
n")
outerVariable = 10
def innerFunction() :
"Working in The Scope of Inner Function(Local Scope)"
print("\n----------------LOCAL SCOPE BEGINS HERE-----------------", end
= "\n")
print("\nAssigning The Variable in Local Scope(innerFunction)", end =
"\n")
innerVariable = 20
print("\nAdding The Local Scope Variable With Enclose Scope Variable",
end = "\n")
innerResult = outerVariable + innerVariable
print("\nReturning The innerFunction() Through Return Statement at
Local Scope(innerFunction)", end = "\n")
print("\n----------------LOCAL SCOPE ENDS HERE-----------------", end =
"\n")
print("\n----------------ENCLOSE SCOPE ENDS HERE-----------------", end
= "\n")
return innerResult

print("\nCalling The Inner Function innerFunction() in The Return Statement


of The Outer Function outerFunction()", end = "\n")
print("\nThis Will Make The Outer Function Return Statement To Wait Till The
Inner Function Does Not Returns", end = "\n")
return innerFunction

print("\nAssigning The outerFunction() Call To Another Variable", end = "\n")


returnValueOuterFunction = outerFunction()
print("\nPrinting The Return Value of The Outer Function (returnValueOuterFunction)
: ", returnValueOuterFunction, end = "\n")
print("\nPrinting The Name Space Referenced By The Outer Function (outerFunction())
: ", returnValueOuterFunction.__name__, end = "\n")
print("\nouterFunction() Has Returned Back To Global Scope(Program Level)", end =
"\n")
print("\n----------------GLOBAL SCOPE ENDS HERE-----------------", end = "\n")#!
python3
"Working in The Scope of Global Scope(Program Level)"
import os
os.system("cls")
print("\n----------------GLOBAL SCOPE BEGINS HERE-----------------", end = "\n")

def outerFunction() :
"Working in The Scope of Outer Function(Enclosed Scope)"
print("\n----------------ENCLOSE SCOPE BEGINS HERE-----------------", end =
"\n")
print("\nAssigning The Variable in Enclosed Scope(outerFunction)", end = "\
n")
outerVariable = 10
def innerFunction() :
"Working in The Scope of Inner Function(Local Scope)"
print("\n----------------LOCAL SCOPE BEGINS HERE-----------------", end
= "\n")
print("\nAssigning The Variable in Local Scope(innerFunction)", end =
"\n")
innerVariable = 20
print("\nAdding The Local Scope Variable With Enclose Scope Variable",
end = "\n")
innerResult = outerVariable + innerVariable
print("\nReturning The innerFunction() Through Return Statement at
Local Scope(innerFunction)", end = "\n")
print("\n----------------LOCAL SCOPE ENDS HERE-----------------", end =
"\n")
print("\n----------------ENCLOSE SCOPE ENDS HERE-----------------", end
= "\n")
return innerResult

print("\nCalling The Inner Function innerFunction() in The Return Statement


of The Outer Function outerFunction()", end = "\n")
print("\nThis Will Make The Outer Function Return Statement To Wait Till The
Inner Function Does Not Returns", end = "\n")
return innerFunction

print("\nAssigning The outerFunction() Call To Another Variable", end = "\n")


returnValueOuterFunction = outerFunction()
print("\nPrinting The Return Value of The Outer Function (returnValueOuterFunction)
: ", returnValueOuterFunction, end = "\n")
print("\nPrinting The Name Space Referenced By The Outer Function (outerFunction())
: ", returnValueOuterFunction.__name__, end = "\n")
print("\n---------------APPLYING CLOSURE BEGINS HERE---------------", end = "\n")
print("\nPrinting The Value From The Inner Function Scope From Global Scope Using
The Reference of The Outer Function : ", returnValueOuterFunction(), end = "\n")
print("\n---------------APPLYING OF CLOSURE ENDS HERE---------------", end = "\n")
print("\nouterFunction() Has Returned Back To Global Scope(Program Level)", end =
"\n")
print("\n----------------GLOBAL SCOPE ENDS HERE-----------------", end = "\n")

You might also like