Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Lambda Functions in Python | Functions in Python
Introduction to Python(ihor)
course content

Kursinnhold

Introduction to Python(ihor)

Introduction to Python(ihor)

1. First Acquaintance with Python
2. Variables and Types in Python
3. Conditional Statements in Python
4. Other Data Types in Python
5. Loops in Python
6. Functions in Python

book
Lambda Functions in Python

All the functions you've created so far are stored in memory after running the code for the first time. However, sometimes you may not want to define a separate function especially for simple, straightforward tasks. In these cases, lambda function can be useful, as it creates anonymous functions.

python

But not all functions discussed can be converted into lambda functions. Typically, lambda functions are best suited for concise operations that fit within a single line.

12345
# Define lambda function sum_squared = lambda x, y: (x + y) ** 2 # Test print('Sum of 2 and 3 squared is', sum_squared(2, 3))
copy
question mark

What is the purpose of a lambda function?

Select the correct answer

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 6. Kapittel 11
Vi beklager at noe gikk galt. Hva skjedde?
some-alt