0
0
Matplotlibdata~20 mins

Box plot with plt.boxplot in Matplotlib - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Box Plot Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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()
AA box plot showing median around 9, with whiskers from 6 to 15
BA box plot showing median around 10, with whiskers from 7 to 15
CA box plot showing median around 8, with whiskers from 5 to 12
DA box plot showing median around 7.5, with whiskers from 5 to 15
Attempts:
2 left
💡 Hint
Remember the median is the middle value when data is sorted.
data_output
intermediate
2: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()
A2
B0
C1
D3
Attempts:
2 left
💡 Hint
Outliers are points outside 1.5 times the interquartile range from the quartiles.
visualization
advanced
2: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?
Aplt.boxplot(data, vert=False)
Bplt.boxplot(data, orientation='horizontal')
Cplt.boxplot(data, vert=True)
Dplt.boxplot(data, horizontal=True)
Attempts:
2 left
💡 Hint
Check the vert parameter in plt.boxplot.
🧠 Conceptual
advanced
1:30remaining
What does the box in a box plot represent?
In a box plot created by plt.boxplot, what does the box itself show?
AThe range between minimum and maximum values
BThe median and outliers
CThe mean and standard deviation
DThe interquartile range (from Q1 to Q3)
Attempts:
2 left
💡 Hint
Think about the middle 50% of the data.
🔧 Debug
expert
2: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()
Aplt.boxplot does not accept keyword arguments
Borientation='sideways' is not a valid parameter value
Cplt.boxplot requires data to be a pandas DataFrame
Ddata must be a numpy array, not a list
Attempts:
2 left
💡 Hint
Check the parameters accepted by plt.boxplot.