There is a function add_functions(f,g)
using Python lambda and
I want the return value to be f(x)+g(x)
.For example,
f=add_functions (lambdax:x*2, lambdax:x+1)
If you run f(2)
, the results are as follows:
f(2)#returns(2*2)+(2+1)=7
How do I write the contents of this add_functions
function?
I would appreciate it if you could let me know.
The hint reads as follows:
You can directly return a lambda
python
As the hint says, the lambda expression itself should be a return value.
default_functions(f,g):
return lambdax —f(x)+g(x)
--From comment by metropolis.
© 2024 OneMinuteCode. All rights reserved.