문제
다음 Python 프로그램의 실행 결과는?
Pythondef mystery(func, data): return [func(x) for x in data if x % 2 == 0] result = mystery(lambda n: n ** 2, [1, 2, 3, 4, 5]) print(len(result)) print(sum(result))
① 2 20 ② 3 20 ③ 2 25 ④ 5 55
정답
1번
해설
짝수만 필터링하면 2, 4이고, 각각 제곱하면 4, 16이다. 따라서 길이는 2, 합은 20이다.