Sunday, August 16, 2015

What is difference between lamda and def in Python?


(i) def may have multiple expressions. On the other hand, lamda can have single expression only.

(ii) def creates a function and assigns a name so as to call it later. lambda creates a function and returns the function itself

(iii) In case of def, we may have a return statement. But in case of lambda there can't be any return statements.

(iv) lambda can be used inside list, dictionary.

5 Python: What is difference between lamda and def in Python? (i) def may have multiple expressions. On the other hand, lamda can have single expression only. (ii) def creates a function and assigns ...

No comments :

Post a Comment