Challenge - 5 Problems
Histogram Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What does this histogram represent?
Look at the code that creates a histogram. What does the histogram show about the data?
Matplotlib
import matplotlib.pyplot as plt import numpy as np data = np.random.normal(loc=0, scale=1, size=1000) plt.hist(data, bins=20) plt.show()
Attempts:
2 left
💡 Hint
Think about what a histogram does with data points and bins.
✗ Incorrect
A histogram groups data points into bins and shows how many points fall into each bin, revealing the shape of the data distribution.
❓ data_output
intermediate2:00remaining
Number of bins effect on histogram
What happens to the histogram output if you increase the number of bins from 5 to 50 for the same data?
Matplotlib
import matplotlib.pyplot as plt import numpy as np data = np.random.uniform(0, 10, 1000) plt.hist(data, bins=5) plt.show() plt.hist(data, bins=50) plt.show()
Attempts:
2 left
💡 Hint
More bins means dividing data into smaller groups.
✗ Incorrect
Increasing bins divides data into smaller intervals, showing finer details of the distribution shape.
❓ visualization
advanced2:30remaining
Identify the distribution type from histogram
Given the histogram plot code below, what type of distribution does the data most likely have?
Matplotlib
import matplotlib.pyplot as plt import numpy as np data = np.random.exponential(scale=1.0, size=1000) plt.hist(data, bins=30) plt.show()
Attempts:
2 left
💡 Hint
Look for a shape with a peak near zero and a tail stretching right.
✗ Incorrect
Exponential distributions have many small values and a long tail to the right, unlike normal or uniform distributions.
🧠 Conceptual
advanced2:00remaining
Why histograms are useful for understanding data
Why do data scientists use histograms to understand data distributions?
Attempts:
2 left
💡 Hint
Think about what visual summaries help you see quickly.
✗ Incorrect
Histograms group data into bins and show frequencies, helping to see shape, spread, and unusual values easily.
🔧 Debug
expert2:30remaining
Why does this histogram code produce an error?
Look at the code below. Why does it raise an error when trying to plot the histogram?
Matplotlib
import matplotlib.pyplot as plt import numpy as np data = np.random.normal(0, 1, 100) plt.hist(data, bins='ten') plt.show()
Attempts:
2 left
💡 Hint
Check the type of the 'bins' argument.
✗ Incorrect
The 'bins' argument must be an integer number of bins or a list of bin edges, not a string.