728x90 반응형 operator2 파이썬 reduce 함수 정리 from functools import reduce reduce함수는 functools 의 내장 모듈로 이렇게 호출을 통해서 사용이 가능한데요 이 함수는 여러 데이터에 대한 누적연산을 반환하는 기능을합니다 😮 functools.reduce (함수, sequence) => Value 반환 특히 이 함수에 어떤 값을 넣는지에 따라서 유용한 활용이 가능한데요 몇가지 예시를 통해 이 함수가 어떤 기능을 하는지 살펴보겠습니다 from functools import reduce def sum(a,b): return a+b reduce(sum,[1,2,3,4]) >> 10 이렇게 간단한 sum 함수를 인자로 넣고 뒤의 sequence를 적용하면 ((1+2)+3)+4 = 10이 나오죠 reduce함수는 복잡한 연산이 .. 2022. 10. 1. Leetcode 150. Reverse Polish Notation (Stack) https://leetcode.com/problems/evaluate-reverse-polish-notation/ Evaluate Reverse Polish Notation - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Polish Notation이 궁금하신 분들은 아래 위키 백과를 참조하시길 바랍니다 더보기 https://ko.wikipedia.org/wiki/%EC%97%AD%ED%8F%B4%EB%9E%80%EB%93%9C_%ED%91%9C%EA%B8%B.. 2022. 9. 22. 이전 1 다음 728x90 반응형