Sênior
4 de outubro de 2026Encontre o bug: Data Analytics
Um trecho de código. Encontre o bug, ou prove que não existe nenhum.
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 resultsClique nas linhas que causam o problema.
Seu veredito
Uma tentativa por dia. A resposta aparece logo depois.
Mantenha sua sequência
Crie uma conta para manter sua sequência e acompanhar seu progresso.