Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
lambda functions | Functions
Learn Python from Scratch
course content

Conteúdo do Curso

Learn Python from Scratch

Learn Python from Scratch

1. The basics
2. Arithmetic operations
3. Common data types
4. Conditional statements
5. Other data types
6. Loops
7. Functions

booklambda functions

All the functions we defined were previously saved in memory after the first code running. But sometimes there is no need to define a separate function, especially if we need to make simple actions. In that case, we can define anonymous Lambda functions in Python have the following syntax:

lambda var1, var2, ... : something...

For example, we can rewrite our first function with lambda function (returns the sum of two numbers squared)

1234
# define lambda function sq = lambda x, y: (x+y)**2 # test it print('Sum of 2 and 3 squared is', sq(2,3))
copy

Tarefa

Define a lambda function doing the same as in Chapter 2 (function with three arguments which returns the sum of tripled first number, doubled second and third and all raised to the second power.)

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 7. Capítulo 7
toggle bottom row

booklambda functions

All the functions we defined were previously saved in memory after the first code running. But sometimes there is no need to define a separate function, especially if we need to make simple actions. In that case, we can define anonymous Lambda functions in Python have the following syntax:

lambda var1, var2, ... : something...

For example, we can rewrite our first function with lambda function (returns the sum of two numbers squared)

1234
# define lambda function sq = lambda x, y: (x+y)**2 # test it print('Sum of 2 and 3 squared is', sq(2,3))
copy

Tarefa

Define a lambda function doing the same as in Chapter 2 (function with three arguments which returns the sum of tripled first number, doubled second and third and all raised to the second power.)

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 7. Capítulo 7
toggle bottom row

booklambda functions

All the functions we defined were previously saved in memory after the first code running. But sometimes there is no need to define a separate function, especially if we need to make simple actions. In that case, we can define anonymous Lambda functions in Python have the following syntax:

lambda var1, var2, ... : something...

For example, we can rewrite our first function with lambda function (returns the sum of two numbers squared)

1234
# define lambda function sq = lambda x, y: (x+y)**2 # test it print('Sum of 2 and 3 squared is', sq(2,3))
copy

Tarefa

Define a lambda function doing the same as in Chapter 2 (function with three arguments which returns the sum of tripled first number, doubled second and third and all raised to the second power.)

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

All the functions we defined were previously saved in memory after the first code running. But sometimes there is no need to define a separate function, especially if we need to make simple actions. In that case, we can define anonymous Lambda functions in Python have the following syntax:

lambda var1, var2, ... : something...

For example, we can rewrite our first function with lambda function (returns the sum of two numbers squared)

1234
# define lambda function sq = lambda x, y: (x+y)**2 # test it print('Sum of 2 and 3 squared is', sq(2,3))
copy

Tarefa

Define a lambda function doing the same as in Chapter 2 (function with three arguments which returns the sum of tripled first number, doubled second and third and all raised to the second power.)

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 7. Capítulo 7
Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
some-alt