Python Lambda Function
dusa

dusa @imdusa

About: I write short articles about everything I learn.

Joined:
May 16, 2024

Python Lambda Function

Publish Date: Nov 18 '24
0 0

Functions that we defined anonymously and one-liner in Python are called lambda functions. Accept multiple parameters, performs a single action. It provides a cleaner structure by writing less code for simple mathematical or conversion operations.

Image description

In the lambda function (:) the parts before this sign are parameters. The parts after this sign are the operations to be performed.

Let's compare “def” and “lambda” with an example:

Image description

def and lambda perform the same function. In other words, it takes the square of the entered number. But look at the cleanliness of the lambda written in a single line.

Comments 0 total

    Add comment