Q50: How do map(), filter(), and functools.reduce() operate?
map(fn, iterable): Appliesfnto every item, returning a lazy iterator.filter(fn, iterable): Filters elements wherefn(item)evaluates truthy, returning a lazy iterator.reduce(fn, iterable): Accumulates elements sequentially into a single aggregate result.
Key Takeaways
mapandfilterreturn lazy iterators.reduceaggregates sequence items down to a single value.
Knowledge Check
In which module does the reduce() function reside in Python 3?