Programming with Python

⌘K
  1. Home
  2. Docs
  3. Programming with Python
  4. Variables, Expression and...
  5. Function
  6. Anonymous Function

Anonymous Function

  • Anonymous functions are special functions which are not declared using standard def keyword
  • lambda keyword is used to create small anonymous function
  • 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

Example,

x=lambda a,b: a+b
print(x(2,3))

Output,

5

Loading

Views: 0

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments