I am studying the properties of functions in Python, and I came across an exercise that asks:
Write a function that returns the strength of a number. Conditions: a function can take only one argument and must use another function to return the power value of a given number.
Code that solves this exercise:
def power(x):
return lambda y: y**x
For example, if we want to know the value of power: 2 ^ 3, we will call the function as follows: power (3) (2)
Here is what I would like to know:
Is there a way to write a function that, when called, has a similar structure: function () () (). In other words, is it possible to write a function that requires three or more parentheses () () () when called? If possible, could you give me an example of the code for this function and explain it briefly?
also:
def power(x):
def power_extra(y):
return y
def power_another(z):
return z
return power_extra and power_another
?