Program Console Vignaankosh.com
Execution Panel
Console is empty.
Combine map + filter + reduce in a single program is an interactive PYTHON dry run visualizer from the Special programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.
This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.
from functools import reduce
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# Pipeline: filter even → square → sum of first 5
result = reduce(
lambda acc, x: acc + x,
list(map(lambda x: x ** 2, filter(lambda x: x % 2 == 0, numbers)))[:5]
)
print(f"Sum of squares of first 5 even numbers: {result}")
# One-liner version
result2 = reduce(lambda a, b: a + b, list(map(lambda x: x ** 2, filter(lambda x: x % 2 == 0, numbers)))[:5])
print(f"Same result: {result2}")
# Generic pipeline function
def pipeline(data, *functions):
for func in functions:
data = func(data)
return data
result3 = pipeline(
numbers,
lambda x: filter(lambda n: n % 2 == 0, x), # Filter even
lambda x: map(lambda n: n ** 2, x), # Square them
lambda x: list(x)[:5], # Take first 5
lambda x: reduce(lambda a,b: a+b, x) # Sum them
)
print(f"Using pipeline function: {result3}")