# Lambda Functions in Python

Learn to write and use lambda functions in Python.

Ever heard of something called ** Anonymous functions?** An anonymous function in Python is a function that is defined without a name.

While functions in Python are defined using the

keyword, anonymous functions are defined using the **def**** lambda** keyword. Hence, they are also called

**.**

**lambda functions****Syntax of Lambda functions**

```
lambda argument: expression
argument - The argument to pass into
your lambda function
```

**Code**

```
# Normal Function
def return_squared(x):
return x**2
# Lambda Function
return_squared = lambda x : x**2
```

Notice, the absence of a function name in the Lambda function. Also, the

keyword is replaced with a **def**

keyword.**lambda**

is the lambda function. Here x is the argument and **lambda x: x**2**

is the expression that gets evaluated and returned as a **x**2**** function object**.

It’s also easy to call lambda functions.

**Here is the difference between a normal function in Python vs a Lambda function.**

```
# Normal Function
def return_squared(x):
return x**2
result = return_squared(5)
print(result)
# Lambda Function
return_squared = lambda x : x**2
result = return_squared(5)
print(result)
```

**Output**

```
25
25
```

**Multiple arguments with lambda function**

You can provide as many arguments you want with lambda function.

**Code**

```
addition = lambda x,y:x+y
print(addition(5,3))
```

**Output**

`8`

**Advantages of Lambda functions**

- Fewer Lines of Code.
- Can be easily used with

,**filter**

and**map**

methods.**reduce**

**Check out my YouTube video on lambda Function to get a better understanding of the concept.**