Senior
October 4, 2026Spot the bug: Data Analytics
One snippet. Find the bug, or prove there isn't one.
python
1from typing import Iterable
2
3def compute_weighted_mean(values: Iterable[float], weights: Iterable[float]) -> float:
4 total_weight = sum(weights)
5 weighted_sum = sum(v * w for v, w in zip(values, weights))
6 return weighted_sum / total_weight
7
8def process_batch(metrics: dict) -> dict:
9 results = {}
10 for key, (values, weights) in metrics.items():
11 results[key] = compute_weighted_mean(values, weights)
12 return resultsClick the lines that carry the problem.
Your verdict
One attempt per day. The answer shows up right after.
Keep your streak
Create an account to keep your streak and track your progress.