Skip to main content
πŸ”’ Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial β†’
⚑
← Coursesβ€ΊSenior Deep-DivesModule 4 Β· Memory + profiling Β· Recapβ€ΊError handling: exceptions vs Result typesquiz86 / 161
+100 XP
Task
πŸ“ **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

Question

πŸ“ **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.