More Transformations
def multiply(x, y):
return x * y
def add(x, y):
return x + y
def self_math(math_func):
def inner_func(x):
return math_func(x, x)
return inner_func
square_func = self_math(multiply)
double_func = self_math(add)
print(square_func(5))
# prints 25
print(double_func(5))
# prints 10Assignment
Tip
Solution
What's happening:
Example Usage:
Last updated