example이라는 함수의 매개변수인 f에 함수를 대입
def multiplication(x): return x*2 def example(f,z): return f(z) + 1 example(multiplication,3)
7
lambda 함수를 이용한 방법
multiplication = lambda x: x*2 def example(f,z): return f(z) + 1 example(multiplication,3)
7
'Language > Python' 카테고리의 다른 글
[Python] Django 프로젝트 생성하기 (1) | 2024.12.17 |
---|---|
[Python] 네이버 카페 게시글 크롤링 selenium, bs4 (2) | 2023.09.09 |
[Python] 데이터프레임 합치기, 중복 행 제거 (0) | 2021.02.24 |
[Python] len()과 size()의 차이점 (0) | 2021.01.30 |
[Python] Numpy 모듈 정리(zeros ,random,argmax) (1) | 2021.01.28 |