Senior
4 ottobre 2026Trova il bug: Data Analytics
Uno snippet di codice. Trova il bug, o dimostra che non ce n'è.
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 resultsClicca sulle righe che causano il problema.
Il tuo verdetto
Un tentativo al giorno. La risposta appare subito dopo.
Mantieni la tua serie
Crea un account per conservare la tua serie e seguire i tuoi progressi.