+ 1

Lambdas helpsss

why there is no comma before the (-4)? like: print((lambda x: x**2 + 5*x + 4) , (-4)) (on this lesson its like: print((lambda x: x**2 + 5*x + 4) (-4)) )

20th Oct 2022, 2:08 AM
Aisy Danish Mohd Nazry
Aisy Danish Mohd Nazry - avatar
2 Answers
+ 3
(lambda x: x**2 + 5*x + 4) creates a function, this is the equivalent of doing this: def func(x): return x**2 + 5*x + 4 the second part, the (-4) becomes the argument being passed to that function. it would be similar to this: print(func(-4)) I like to see lamdbas as values, it might have been more clear to do this instead: func = (lambda x: x**2 + 5*x + 4) print(func(-4)) I hope this helps :)
20th Oct 2022, 2:31 AM
Apollo-Roboto
Apollo-Roboto - avatar
+ 1
Thank you :)))
20th Oct 2022, 10:34 AM
Aisy Danish Mohd Nazry
Aisy Danish Mohd Nazry - avatar