Build a Data Pipeline
Advanced · Write the code · from Python map(), filter(), reduce(), and Higher-Order Functions
From the lesson: Python map(), filter(), reduce(), and Higher-Order Functions
Picture an assembly line in a factory. Raw materials enter at one end. At the first station, each piece is shaped. At the next station, defective pieces are removed. At the final station, all the good pieces are combined into one finished product.
Read the lessonGiven a list of student scores, build a pipeline that:
1. Filters out failing scores (keep only scores >= 60)
2. Curves each passing score by adding 10 (use map)
3. Caps scores at 100 (use map with min)
Given: [45, 82, 55, 91, 67, 38, 73, 95]
Print the final list.
Expected output:
[92, 100, 77, 83, 100]Hint: to cap at 100, use min(score, 100).
scores = [45, 82, 55, 91, 67, 38, 73, 95]
# Step 1: Filter passing scores (>= 60)
# Step 2: Add 10 bonus points
# Step 3: Cap at 100
More Map, Filter and Reduce exercises
- Square Every NumberBeginner
- Filter Out Short WordsBeginner
- Predict the Pipeline OutputBeginner
- Fix the Broken PipelineIntermediate
- Find the Product with reduce()Intermediate
- Refactor to a List ComprehensionAdvanced
All Python exercises · 50 practice problems · Functions quiz