Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

dusa
dusa

Posted on

Python Lambda Function

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.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

I write short articles about everything I learn.
  • Pronouns
    dusa
  • Work
    Web Developer
  • Joined

More fromdusa

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp