Python Question:

What are uses of lambda?

Python Interview Question
Python Interview Question

Answer:

It used to create small anonymous functions at run time. Like e.g.

def fun1(x):

return x**2

print fun1(2)

it gives you answer 4

the same thing can be done using

sq=lambda x: x**2

print sq(2)

it gives the answer 4


Previous QuestionNext Question
Is python the right choice for Web based Programming?When you need ordered container of things, which will be manipulated, use lists.