:PROPERTIES: :ID: 9d534e89-7f0b-494c-bff6-7b3be05b85d1 :END: #+title: python-lambda #+filetags: :python:notes:functions: A lambda function is a small anonymous function. A lambda function can take any number of arguments, but can only have one expression. Syntax: *lambda arguments : expression* The expression is executed and the result is returned: #+begin_src python :results output # Add 10 to argument a, and return the result: x = lambda a : a + 10 print(x(5)) # Multiply argument a with argument b and return the result: y = lambda a, b : a * b print(y(5, 6)) # Summarize argument a, b, and c and return the result: z = lambda a, b, c : a + b + c print(z(5, 6, 2)) #+end_src #+RESULTS: : 15 : 30 : 13