In [9]:
import functools
def hello_doctor(greet_msg, greet_whom):
return "%s %s, Welcome to the world of robots." %(greet_msg, greet_whom)
## this line works
# hello_doctor = functools.partial(hello_doctor, "R2-D2")
# hello_doctor("Dr.Susan Calvin")
Out[9]:
In [11]:
greet = functools.partial(hello_doctor)
greet("Dr.Susan Calvin")
Out[11]:
In [14]:
welcome = functools.partial(hello_doctor)
welcome("Dr.Susan Calvin")
Out[14]:
In [4]:
def numpower(base, exponent):
return base ** exponent
def square(base):
return numpower(base, 2)
def cube(base):
return numpower(base, 3)
print square(25)
print cube(15)