def functionCreator(txt):
def createdFunction(newTxt):
return txt + " " + newTxt
return createdFunction
print(functionCreator("hello")("world"))
def sum(a,b):
return a+b
def calculate(function,a,b):
return function(a,b)
calculate(sum,3,4)
#returns 7
def greet(name, msg):
"""This function greets to
the person with the provided message"""
print("Hello", name + ', ' + msg)
greet("Monica", "Good morning!")
def shout(text):
return text.upper()
print(shout('Hello World'))
yell = shout
print(yell('Hello'))
def first():
print("first")
def second():
print("second")
f = first
s = second
def y(l):
l()
y(f)
#first
y(s)
#second
def perform(fun, *args):
fun(*args)
def action1(args):
# something
def action2(args):
# something
perform(action1)
perform(action2, p)
perform(action3, p, r)