def shout(text):
return text.upper()
print shout('Hello')
yell = shout
print yell('Hello')
def shout(text):
return text.upper()
def whisper(text):
return text.lower()
def greet(func):
# storing the function in a variable
greeting = func("Hi, I am created by a function passed as an argument.")
print greeting
greet(shout)
greet(whisper)
def create_adder(x):
def adder(y):
return x+y
return adder
add_15 = create_adder(15)
print add_15(10)
Detailed Ref : https://www.geeksforgeeks.org/first-class-functions-python/