-
[Python tutorial] 15. Lambda코딩/Python 2022. 12. 21. 17:16728x90
Lambda
Syntax:
lambda arguments : expression
x = lambda a : a + 10 print(x(5)) # 15
x = lambda a, b : a * b print(x(5, 6)) # 30
x = lambda a, b, c : a + b + c print(x(5, 6, 2)) # 13
def myfunc(n): return lambda a : a * n # myfunc는 lambda를 return mydoubler = myfunc(2) mytripler = myfunc(3) print(mydoubler(11)) # 22 print(mytripler(11)) # 33
728x90'코딩 > Python' 카테고리의 다른 글
[Python tutorial] 17. Try...Except (0) 2022.12.21 [Python tutorial] 16. Classes, Objects and Inheritance (1) 2022.12.21 [Python tutorial] 14. Functions (0) 2022.12.21 [Python tutorial] 13. Control flow, Loop, Iterator (0) 2022.12.21 [Python tutorial] 12. Control flow, If...else (0) 2022.12.21