Challenge - 5 Problems
Box Plot Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What does this box plot code output?
Look at this code that creates a box plot. What will the plot show about the data?
Matplotlib
import matplotlib.pyplot as plt data = [7, 8, 5, 6, 9, 10, 12, 15, 7, 8] plt.boxplot(data) plt.show()
Attempts:
2 left
💡 Hint
Remember the median is the middle value when data is sorted.
✗ Incorrect
The median of the data is 8. The whiskers extend to the minimum and maximum values within 1.5 times the interquartile range, which are 5 and 12 here.
❓ data_output
intermediate2:00remaining
How many outliers are shown by this box plot?
This code creates a box plot. How many points will be shown as outliers?
Matplotlib
import matplotlib.pyplot as plt data = [10, 12, 14, 15, 16, 18, 20, 100, 105] plt.boxplot(data) plt.show()
Attempts:
2 left
💡 Hint
Outliers are points outside 1.5 times the interquartile range from the quartiles.
✗ Incorrect
The values 100 and 105 are far from the rest and will be marked as outliers, so 2 points.
❓ visualization
advanced2:00remaining
Which option produces a box plot with horizontal orientation?
You want to create a horizontal box plot using plt.boxplot. Which code does this correctly?
Attempts:
2 left
💡 Hint
Check the vert parameter in plt.boxplot.
✗ Incorrect
The correct parameter to set horizontal orientation is vert=False. orientation='horizontal' is not a valid parameter.
🧠 Conceptual
advanced1:30remaining
What does the box in a box plot represent?
In a box plot created by plt.boxplot, what does the box itself show?
Attempts:
2 left
💡 Hint
Think about the middle 50% of the data.
✗ Incorrect
The box shows the interquartile range, which is the range between the first quartile (Q1) and third quartile (Q3).
🔧 Debug
expert2:30remaining
Why does this box plot code raise an error?
This code tries to create a box plot but raises an error. What is the cause?
Matplotlib
import matplotlib.pyplot as plt data = [1, 2, 3, 4, 5] plt.boxplot(data, orientation='sideways') plt.show()
Attempts:
2 left
💡 Hint
Check the parameters accepted by plt.boxplot.
✗ Incorrect
plt.boxplot does not accept an 'orientation' parameter (use 'vert' instead). Passing 'orientation' causes an error.