Programming Languages Python Subjective
Sep 30, 2025

Explain the difference between `map()`, `filter()`, and `reduce()` with examples.

Detailed Explanation
map(): Applies function to all items\nlist(map(lambda x: x**2, [1,2,3])) # [1,4,9]\n\nfilter(): Filters items based on condition\nlist(filter(lambda x: x%2==0, [1,2,3,4])) # [2,4]\n\nreduce(): Reduces to single value\nfrom functools import reduce\nreduce(lambda x,y: x+y, [1,2,3,4]) # 10
Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback