Amazing technological breakthrough possible @S-Logix pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

What is anonymous function or lambda function in python?

Description

To see what is lambda function and syntax of lambda function in python3.

Process

Anonymous or lambda function.

   Lambda functions are small functions usually not more than a line.

   Its also called as one line function.

   Lambda function can have any number of arguments but only one expression.

   It defined with keyword lambda.

   Its mostly used for mathematical expression

Sample Code

#lambda function to double the input
d = lambda x: x * 2
print(“——First output——\n”)
print(d(6))

#lambda functions with mapping
list1=[2,8,6,3,7,5,4]
print(“——Second output——\n”)
newlist=list(map(lambda x: x * 2,list1))
print(newlist)

Screenshots
What is anonymous function or lambda function in python