람다 함수

Python 함수 입문

Hugo Bowne-Anderson

Instructor

람다 함수

raise_to_power = lambda x, y: x ** y

raise_to_power(2, 3)
8
Python 함수 입문

익명 함수

  • 함수 map은 두 인수를 받습니다: map(func, seq)

  • map()은 시퀀스의 모든 원소에 함수를 적용합니다

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]
Python 함수 입문

연습해 봅시다!

Python 함수 입문

Preparing Video For Download...