Skip to content
Kuza Ndoto Academy

Data Science Quiz

Beginner → IntermediateChapter 6 · Page 20 of 204 min readUpdated 15 Nov 2026

Test what you've learned across the Data Science series. Try each question before opening the answer. If you get one wrong, follow the link back to the page that covers it.

Workflow and NumPy

1. Which step should come first in a data science project?

a) Cleaning the data   b) Asking a clear question   c) Building a model   d) Drawing charts

Show answer

b) A specific question decides what data you need and what analysis makes sense. See The Data Science Workflow.

2. What does this code print?

import numpy as np
print(np.array([1, 2, 3]) * 2)
Show answer

[2 4 6]. Arithmetic on an array is element-wise. (A Python list would print [1, 2, 3, 1, 2, 3].)

3. What does this code print?

a = np.array([10, 20, 30, 40, 50])
print(a[1:4])
Show answer

[20 30 40]. Slicing starts at position 1 and stops before position 4. See Indexing & Slicing.

4. What does this code print?

arr = np.array([[1, 2, 3],
                [4, 5, 6]])
print(arr.sum(axis=0))
Show answer

[5 7 9]. axis=0 collapses the rows, giving one total per column. axis=1 would give [ 6 15].

pandas

5. What is the difference between a Series and a DataFrame?

Show answer

A Series is a single labelled column of values; a DataFrame is a table of several Series that share the same index. See Series & DataFrames.

6. After sorting, df.loc[0] and df.iloc[0] return different rows. Why?

Show answer

loc selects by label (the row whose index label is 0, wherever it now sits), while iloc selects by position (whatever row is now first).

7. Why does df[df["units"] > 10 and df["price"] < 200] fail, and how do you fix it?

Show answer

Python's and needs a single True/False, not a whole Series, so pandas raises "The truth value of a Series is ambiguous". Use & with brackets: df[(df["units"] > 10) & (df["price"] < 200)]. See Filtering & Sorting.

8. What is wrong with df[df["county"] == "Nairobi"]["units"] = 0?

Show answer

It is chained assignment: the value is set on a temporary copy, so df is not changed (and pandas 2.x shows a SettingWithCopyWarning). Write df.loc[df["county"] == "Nairobi", "units"] = 0. See Cleaning Data.

9. What does df.groupby("county")["revenue"].sum() return?

Show answer

A Series with one row per county (the index), holding the total revenue for each county. See Grouping & Aggregation.

Visualisation

10. Which chart best shows how monthly sales changed over a year?

a) Pie chart   b) Line chart   c) Histogram   d) Scatter plot

Show answer

b) Line charts show change over an ordered sequence such as time. See Choosing the Right Chart.

11. By default, what does the height of each bar in sns.barplot() represent?

Show answer

The mean of each group, not the total. Pass estimator="sum" for totals. See Seaborn.

Statistics

12. For the data 3, 5, 7, 9 and 100, what are the mean and median, and which better describes a typical value?

Show answer

Mean = 124 ÷ 5 = 24.8; median = 7. The median is more typical, because the extreme value 100 drags the mean upwards. See Descriptive Statistics.

13. pd.Series([2, 4, 6]).std() gives 2.0 but np.std(np.array([2, 4, 6])) gives about 1.633. Why?

Show answer

pandas defaults to the sample standard deviation (ddof=1, divide by n − 1 = 2: √(8 ÷ 2) = 2), while NumPy defaults to the population version (ddof=0, divide by n = 3: √(8 ÷ 3) ≈ 1.633).

14. A study finds r = −0.85 between the price of airtime bundles and the number bought. What does this mean?

Show answer

A strong negative linear relationship: higher prices go with fewer bundles bought. On its own, it doesn't prove that price causes the drop. See Correlation.

15. A t-test comparing two groups gives p = 0.03. Which statement is correct?

  • a) There is a 3% chance the null hypothesis is true.
  • b) If there were truly no difference, a result at least this extreme would occur about 3% of the time.
  • c) The difference is large and important.
  • d) There is a 97% chance the alternative hypothesis is true.
Show answer

b) A p-value is calculated assuming the null hypothesis is true. It is not the probability that either hypothesis is true, and it says nothing about the size of the effect. See Hypothesis Testing.

Key points

  • 12 or more correct: you're ready for real projects. Try Project: Sales Analysis with your own data.
  • 8 to 11: revisit the pages linked in the answers you missed.
  • Fewer than 8: work through the series again, running every example yourself.
  • Next step: use these skills to build models in the Machine Learning series.
You've reached the end of the seriesGet certified in Data ScienceContinue in Kuza Ndoto Academy with projects, mentor feedback and a certificate.
→

Tip: use the ← and → keys to move between pages.