Challenge - 5 Problems
Categorical Visualization Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this bar chart code?
Look at the code below that creates a bar chart for fruit counts. What will the heights of the bars be?
Matplotlib
import matplotlib.pyplot as plt fruits = ['Apple', 'Banana', 'Cherry'] counts = [10, 15, 7] plt.bar(fruits, counts) plt.show()
Attempts:
2 left
💡 Hint
Check the order of the counts list and how it matches the fruits list.
✗ Incorrect
The plt.bar function pairs each fruit with the count at the same index. So Apple gets 10, Banana 15, and Cherry 7.
❓ data_output
intermediate1:30remaining
How many categories are shown in this pie chart?
Given this pie chart code, how many slices (categories) will appear?
Matplotlib
import matplotlib.pyplot as plt labels = ['Red', 'Blue', 'Green', 'Yellow'] sizes = [20, 30, 25, 25] plt.pie(sizes, labels=labels) plt.show()
Attempts:
2 left
💡 Hint
Count the number of labels provided.
✗ Incorrect
Each label corresponds to one slice in the pie chart, so there are 4 slices.
❓ visualization
advanced2:30remaining
Which option produces a correct stacked bar chart?
You want to show sales of two products over three months stacked in one bar per month. Which code produces the correct stacked bar chart?
Matplotlib
import matplotlib.pyplot as plt months = ['Jan', 'Feb', 'Mar'] sales_A = [5, 7, 6] sales_B = [3, 4, 5]
Attempts:
2 left
💡 Hint
Stacked bars need the bottom parameter to stack the second bar on top of the first.
✗ Incorrect
Option C stacks sales_B on top of sales_A using the bottom parameter. Option C tries to add lists which causes an error. Option C overlays bars without stacking. Option C stacks in wrong order causing incorrect visualization.
🧠 Conceptual
advanced1:30remaining
Why is categorical visualization important in data science?
Which option best explains why visualizing categorical data helps in data science?
Attempts:
2 left
💡 Hint
Think about how charts help us understand group differences.
✗ Incorrect
Categorical visualization helps us see how different groups compare, making patterns easier to spot.
🔧 Debug
expert2:00remaining
What error does this code raise?
This code tries to plot a bar chart but fails. What error will it raise?
Matplotlib
import matplotlib.pyplot as plt categories = ['A', 'B', 'C'] values = [10, 20] plt.bar(categories, values) plt.show()
Attempts:
2 left
💡 Hint
Check if the categories and values lists have the same length.
✗ Incorrect
The categories list has 3 items but values has only 2, so matplotlib raises a ValueError about size mismatch.