map(fn, iterable)
nums = [1, 2, 3, 4] squared = list(map(lambda n: n*n, nums)) # [1, 4, 9, 16]
filter(fn, iterable)
evens = list(filter(lambda n: n%2==0, nums)) # [2, 4]
functools.reduce(fn, iterable)
from functools import reduce total = reduce(lambda a, b: a + b, nums) # 10 prod = reduce(lambda a, b: a * b, nums) # 24
List Comprehension Alternatives
For readability, many Python programmers prefer comprehensions:
squared = [n*n for n in nums] evens = [n for n in nums if n % 2 == 0]
When Each Wins
- map/filter — short, reusing an existing function.
- comprehension — readable, multiple conditions, transformations.
- reduce — sums, products, custom aggregation.
Practise this on PyForm — free
PyForm runs Python in your browser with an AI tutor trained for HKDSE. No install, no credit card.
Open PyForm →