Programming with Python

  1. Home
  2. Docs
  3. Programming with Python
  4. Functions in python
  5. Anonymous Functions

Anonymous Functions

A function without any name is called an anonymous function. It is also known as lambda function or lambda expression.

An anonymous function can take a number of arguments but can only have one expression.

One is free to use lambda functions wherever function objects are required.

We use lambda functions when we require a nameless function for a short period of time.

Syntax:-

lambda argument: expression

e.g.,

f=lambda a: a*a
result =f(5)
print(result)
Output- 25

This is all about anonymous function in python.

Was this article helpful to you? Yes No

How can we help?