Python Lambda Function

Selin Yazıcıoğlu
2 min readJun 6, 2022

--

Hello guys! I will mention about lambda function in this article. I will code on Jupyter Notebook in Python. Okay, let’s start!

Lambda Function

Firstly, I want to explain Why we use to lambda function? What does work? How does it work?

We can use lambda functions when we need the functionality of a function, but cannot define a function as a location, or where it is difficult to define a function.

How we can write it?

lambda argument: expression

<function __main__.<lambda>(argument)>

I would like to explain the difference between the def command and lambda with an example.

Both give the same result.

Using with map( )

In Python, all the elements of a specified list are sent to a function whose reference is specified through the map function, and the desired operation is performed on the list.

Using with filter()

In the Map function, each number in the list is sent to the function and is processed and sent back, but we can apply a filter to the numbers that will return with the filter method.

I have examples related to lambda functions on Github. If you want to learn more then you can check out my Github account. Here link is:

https://github.com/Selin-Y/python-projects/blob/main/Lambda%20Function.ipynb

I hope while you’re reading my article you can enjoy it!

See you on another topic :)

If you want, you can follow me at these links:

--

--