-
def outer(a, b): def inner(): return a + b return inner f = outer(1, 2) r = f() # 이 시점에 1 + 2 가 실행됨, lazy evaluation? print(r) # 3 #################################################################### # pi 값을 변경하면서 계산하고 싶다.. def circle_area_func(pi): def circle_area(radius): return pi * radius * radius return circle_area cal = circle_area_func(3.14) cal2 = circle_area_func(3.141592) print(cal(10)) # 314.0 print(cal2(10)) # 314.1592
'python > 기본' 카테고리의 다른 글
Lambda (0) 2022.04.29 Decorator / contextmanager (0) 2022.04.29 Function, kwargs (0) 2022.04.29 range, enumerate, zip (0) 2022.04.29 For (0) 2022.04.29