If you are facing any issue in playing video please use Firefox browser.

# Description

Lambda Functions in Python

In this lecture we will see that, What is Lambda Function and How to use it ?

Lambda function or Anonymous function

Anonymous function is a function that is defined without a name. Why normal functions are defined using the 'def' keyword, in Python anonymous functions are defined using the 'lambda' keyword. Hence, anonymous functions are also called lambda functions.

Syntax :

lambda arguments: expression

Example :

m= lambda x:x*2

print(m(7))

Another Example :

m=lambda x:print(x**2)

m(5)

O/P : 25

Lambda function with no argument

m=lambda : print('hello')

m()

Lambda function with more than one argument

m=lambda x,n:x**n

print(m(5,3))

Lambda function and user defined function

def g(number):

return lambda n: number**n

Call a function -

x=power(3)

print(x(3))

print(x(5))

Lambda function with user defined function

def g(number):

return lambda n: number**n

Call a function -

x=g(3)

print(x(3))

print(x(5))

Example :

m=lambda : print('hey')

m()

O/P : hey

Another Example :

m=lambda a,b:print('sum',a+b)

m(25,78)

O/P -

sum=103

Another Example :

'''a*x**2+b*x+c'''

def evaluate (a,b,c):

return lambda x: a*x**2+b*x+c

ans=evaluate(3,5,2)

print (ans(4))

O/P - 70

Function is a very important topic, which is used for code reusability. It makes our code very short and they are very useful for lengthy programs.

# Share With Friend

Have a friend to whom you would want to share this course?

# Download The Apps  ###### Code Scan or Download the app ###### 297K+ Downloads ###### 4.5 Rating ###### 10K+ Reviews • Learn anywhere on the go
• Get regular updates about your enrolled or new courses
• Share content with your friends
• Evaluate your progress through practice tests
• No internet connection needed
• Enroll for the webinar and join at the time of the webinar from anywhere