rewrite the function as a Lambda function: | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

rewrite the function as a Lambda function:

def func (x): return x**4 print (func (7))

19th Mar 2017, 8:24 AM
Peet Van Der Walt
Peet Van Der Walt - avatar
2 Answers
+ 2
myfunc = lambda x: x**4 print(myfunc(7))
19th Mar 2017, 8:38 AM
ChaoticDawg
ChaoticDawg - avatar
0
# Lambda is an anonimous funtion like this # normal method for create a funtion def plus(x,y): return x+y # how use lambda as anonimous funtion sum = lambda x,y:x+y # call the first funtion print(plus(2,5)) # call the anonimous funtion print(sum(2,5)) # the different is the when you define a funtion you have to specify is this funtion has # return or no in the case of lambda we dont specify but it is on it.
21st Mar 2017, 11:03 PM
Rafael Marroquin
Rafael Marroquin - avatar