๐ Modalitร anteprima. Le prime quindici lezioni di Foundations sono gratuite; questa รจ Pro. Avvia un trial di 7 giorni per sbloccare l'editor, i suggerimenti AI e il resto del programma. Carta richiesta, disdici in qualsiasi momento dalla Dashboard.Avvia trial di 7 giorni โ
โ CorsiโบSenior Deep-DivesโบModule 4 ยท Memory + profiling ยท RecapโบGestione degli errori: eccezioni e tipi di risultatiquiz86 / 161
+100 XP
Compito๐ shown in EN
๐ **Task:** Build a small \`memory_estimator(rows, bytes_per_row, overhead_pct)\` that returns total memory in MB (float, 2 decimals):
\`\`\`
total_bytes = rows * bytes_per_row * (1 + overhead_pct / 100)
mb = total_bytes / 1_000_000 # decimal MB โ matches Prometheus/Grafana convention
return round(mb, 2)
\`\`\`
Test for 3 realistic scales: small in-memory cache, mid-size pandas DataFrame, large Redis dataset.
๐ Implement the function above. Tests run automatically.
๐ก **Hint:** Re-read the theory if you get stuck.
๐ฏ Quiz
Domanda
๐ **Task:** Build a small \`memory_estimator(rows, bytes_per_row, overhead_pct)\` that returns total memory in MB (float, 2 decimals):
\`\`\`
total_bytes = rows * bytes_per_row * (1 + overhead_pct / 100)
mb = total_bytes / 1_000_000 # decimal MB โ matches Prometheus/Grafana convention
return round(mb, 2)
\`\`\`
Test for 3 realistic scales: small in-memory cache, mid-size pandas DataFrame, large Redis dataset.
๐ Implement the function above. Tests run automatically.
๐ก **Hint:** Re-read the theory if you get stuck.