Funções lambda

Introdução a Funções em Python

Hugo Bowne-Anderson

Instructor

Funções lambda

raise_to_power = lambda x, y: x ** y

raise_to_power(2, 3)
8
Introdução a Funções em Python

Funções anônimas

  • A função map recebe dois argumentos: map(func, seq)

  • map() aplica a função a TODOS os elementos da sequência

nums = [48, 6, 9, 21, 1]

square_all = map(lambda num: num ** 2, nums)

print(square_all)
<map object at 0x103e065c0>
print(list(square_all))
[2304, 36, 81, 441, 1]
Introdução a Funções em Python

Vamos praticar!

Introdução a Funções em Python

Preparing Video For Download...