Skip to content

STEP 2. 조건문 #3

Description

@letsjo

단계 설명

if 등의 조건문을 사용해 봅시다.

문제 / 코드보기

새로 알게된 점

  • max() 으로 최대값을 찾을 수 있다.

     max([1,2,3]) # 3
  • lambda 라는 메서드가 있었는데, 사용해봐야겠다.

     # lambda 인수1, 인수2, ... : 인수를 이용한 표현식
     >>> sum = lambda a, b: a+b
     >>> sum(3,4)
     7
  • python 에서도 reduce는 있지만, python3부터 내부함수에서 빠져 라이브러리에서 가져와야 한다.

     from functools import reduce
     
     # reduce(function, iterable[, initializer])
     reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) # ((((1+2)+3)+4)+5)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions