Question: I want to know what exactly is `lambda` in python? and where and why it is used.
thanks

Answer: 
Lambdas are not anonymous functions. Lambdas are anonymous *expressions*.

They're accessed like functions, but they're not the same thing. Functions allow complex tasks: flow control, variable declarations and lists of statements containing expressions. Expressions are merely one part of a function, and that's what lambdas give you. They're severely limited compared to functions.

Python does not support anonymous functions. For examples of languages that do, see Javascript and Lua.

(Note: It's correct to call lambdas anonymous functions in functional languages, where the mathematical definition of "function" is used, but in procedural languages the word has a very different meaning than in mathematics.)
`lambda` is a way of defining an anonymous in-line function to accomplish some task versus defining it with the `def` keyword and calling it. Think of it as a shorthand you can use when you won't need to reuse a function. Anywhere you use lambda, you could substitute an explicitly called function: it's use is completely optional and left to the programmer as a matter of coding style.

Example code (without lambda):

```
def numSquared(num):
    return num**2

for i in range(1,11):
    print numSquared(i)

```

Example code (with lambda):

```
for i in range(1,11):
    print (lambda x: x**2)(i)

```

A good beginner's discussion of `lambda`:
[DiveIntPython.org - Lambda](http://diveintopython.net/power_of_introspection/lambda_functions.html "DiveIntoPython - Lambda")