Level015 1

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

#!

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")#!
python3

import os
os.system("cls")

def baseFunction() :
"This is The Base Function in The Application"
print("\nHello! This is The Message From The Base Function", end = "\n")
def callingFunction(callBase) :
"This is The Calling Function To Base Function in The Application"
print("\nHello! This is The Message From The Calling Function", end = "\n")
return callBase()

print("\nMain Module of The Application Begins Here", end = "\n")


print("\n------------------------------------------")
print("\nCalling The Calling Function", end = "\n")
callingFunction(baseFunction)

#! python3

import os
os.system("cls")

def makeUpperCase(inStringFunc) :
def changeUC() :
extrString = inStringFunc()
return extrString.upper()
return changeUC

def outMessage() :
return "we are emotional generation"

print("\nMain Module of The Application Begins Here", end = "\n")


print("------------------------------------------", end = "\n")
print("\nCalling The Function Normally : ", outMessage(), end = "\n")

print("\nCreating The Decorator Here", end = "\n")


print("---------------------------", end = "\n")
decorFuncRef = makeUpperCase(outMessage)

print("\nCalling The Decorator Here", end = "\n")


print("---------------------------", end = "\n")
print("\nCalling The Function Using Decorator : ", decorFuncRef(), end = "\n")#!
python3

import os
os.system("cls")

def makeUpperCase(inStringFunc) :
def changeUC() :
extrString = inStringFunc()
return extrString.upper()
return changeUC

@makeUpperCase
def outMessage() :
return "we are emotional generation"

print("\nMain Module of The Application Begins Here", end = "\n")


print("------------------------------------------", end = "\n")
print("\nCalling The Function Normally : ", outMessage(), end = "\n")

#! python3

import os
os.system("cls")
def calcDivision(inNum, inDeno) :
return inNum / inDeno

print("\nMain Module of The Application Begins Here", end = "\n")


print("------------------------------------------", end = "\n")
inParam01 = int(input("\nPlease Enter The Numerator Value : "))
inParam02 = int(input("\nPlease Enter The Denominator Value : "))

print("\nThe Quotient Calculated is : ", calcDivision(inParam01, inParam02), end =


"\n")

#! python3

import os
os.system("cls")

def divValidate(inDivFunc) :
def evalDivision(inNumerator, inDenominator) :
if inDenominator == 0 :
return "Sorry! Division Cannot Proceed With Denominator as Zero"
return inDivFunc(inNumerator, inDenominator)
return evalDivision

@divValidate
def calcDivision(inNum, inDeno) :
return inNum / inDeno

print("\nMain Module of The Application Begins Here", end = "\n")


print("------------------------------------------", end = "\n")
inParam01 = int(input("\nPlease Enter The Numerator Value : "))
inParam02 = int(input("\nPlease Enter The Denominator Value : "))

print("\nThe Quotient Calculated is : ", calcDivision(inParam01, inParam02), end =


"\n")
#! python3

import os
os.system("cls")

def getUpperCase(inDecoFunc) :
def innerUC() :
inUpperString = inDecoFunc()
return inUpperString.upper()
return innerUC

def applySplit(inDecoFunc) :
def innerSP() :
inSplitString = inDecoFunc()
return inSplitString.split()
return innerSP

@applySplit
@getUpperCase
def callingFunction() :
"This is The Calling Function"
inFullName = input("\nPlease Give Your Full Name : ")
print("\nThe Actual Name Given is : ", inFullName, end = "\n")
return inFullName
print("\nMain Module of The Application Begins Here", end = "\n")
print("\n------------------------------------------")
print("\nThe Returned Decorated Name is : ", callingFunction(), end = "\n")

#! python3

import os
os.system("cls")

def getUpperCase(inDecoFunc) :
def innerUC() :
print("\nWe Are in The Upper Decorator", end = "\n")
inUpperString = inDecoFunc()
return inUpperString.upper()
return innerUC

def applySplit(inDecoFunc) :
def innerSP() :
print("\nWe Are in The Split Decorator", end = "\n")
inSplitString = inDecoFunc()
return inSplitString.split()
return innerSP

@applySplit
@getUpperCase
def callingFunction() :
"This is The Calling Function"
inFullName = input("\nPlease Give Your Full Name : ")
print("\nThe Actual Name Given is : ", inFullName, end = "\n")
return inFullName

print("\nMain Module of The Application Begins Here", end = "\n")


print("\n------------------------------------------")
print("\nThe Returned Decorated Name is : ", callingFunction(), end = "\n")

#! python3

import os
os.system("cls")

def callUpper(inFullName) :
def getUpperCase(inDecoFunc) :
def innerUC() :
return inDecoFunc().upper()+ " " + inFullName.upper()
return innerUC
return getUpperCase

@callUpper("Sathish Yellanki")
def callingFunction() :
"This is The Calling Function"
return " Welcome To The World of Artificial Intelligence"

print("\nMain Module of The Application Begins Here", end = "\n")


print("\n------------------------------------------")
print("\nThe Returned Decorated Name is : ", callingFunction(), end = "\n")

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy