Module 11 Knowledge Check
5 questions. Pass mark 4 out of 5. Answer every question before checking the answer key below, then retry after reading the feedback.
1. When should aggregation happen in SQL rather than pandas?
- A. Never
- B. When the data is large - aggregate in the database and move less data
- C. Always in pandas
- D. Only for text
2. Building SQL by string-concatenating user input risks…
- A. Slower queries
- B. SQL injection and broken quoting
- C. Larger files
- D. Nothing
3. After loading a query result into a DataFrame, the first check should be…
- A. Plot it
- B. Row count and dtypes against what you expected
- C. Sort it
- D. Export to CSV
4. A reproducible analysis notebook must be able to…
- A. Run only once
- B. Re-run top to bottom and produce the same result
- C. Hide its queries
- D. Use random sampling
5. Keeping the SQL in a separate readable file rather than buried in code helps because…
- A. It runs faster
- B. It can be reviewed, diffed, and re-run independently of the notebook
- C. It uses less memory
- D. It avoids joins
---
Answer Key and Explanations
Check these only after attempting every question.
1. B - When the data is large - aggregate in the database and move less data
Pushing work to the database reduces transfer volume and memory pressure.
2. B - SQL injection and broken quoting
Use parameterised queries; this is a correctness and security issue, not a style preference.
3. B - Row count and dtypes against what you expected
Silent type coercion and unexpected row counts invalidate everything downstream.
4. B - Re-run top to bottom and produce the same result
Hidden state from out-of-order cells is the most common cause of unreproducible analysis.
5. B - It can be reviewed, diffed, and re-run independently of the notebook
Reviewability is what turns a query into evidence.
Practical Check
Apply this module to your own work: complete the module activity for *SQL plus Python and pandas for Analysis Workflows*, then write one sentence naming what your result shows and one naming what it does not.
Strong Answer Pattern
A strong answer names the task, the evidence used, the check performed, and the remaining limitation. It avoids "proved", "guaranteed", or "always" unless the evidence genuinely supports it.
