Challenge - 5 Problems
Pie Chart Color Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate1:30remaining
What colors will the pie chart slices have?
Consider this code that creates a pie chart with custom colors. What colors will the slices be?
Matplotlib
import matplotlib.pyplot as plt sizes = [30, 20, 50] colors = ['red', 'green', 'blue'] plt.pie(sizes, colors=colors) plt.show()
Attempts:
2 left
💡 Hint
The colors list is passed to the pie function to set slice colors.
✗ Incorrect
The colors parameter in plt.pie sets the slice colors in order. Here, red, green, and blue are used.
❓ data_output
intermediate1:30remaining
How many slices will be colored orange?
Given this pie chart code, how many slices will be orange?
Matplotlib
import matplotlib.pyplot as plt sizes = [10, 20, 30, 40] colors = ['orange', 'orange', 'blue', 'green'] plt.pie(sizes, colors=colors) plt.show()
Attempts:
2 left
💡 Hint
Count how many times 'orange' appears in the colors list.
✗ Incorrect
The colors list has 'orange' twice, so two slices will be orange.
🔧 Debug
advanced2:00remaining
Why does this pie chart ignore the colors list?
This code tries to color slices but all slices appear gray. What is the error?
Matplotlib
import matplotlib.pyplot as plt sizes = [25, 25, 25, 25] colors = ['red', 'green', 'blue', 'yellow'] plt.pie(sizes, color=colors) plt.show()
Attempts:
2 left
💡 Hint
Check the exact parameter name for slice colors in plt.pie.
✗ Incorrect
The correct parameter name is 'colors'. Using 'color' is ignored, so default colors appear.
❓ visualization
advanced2:00remaining
Which option shows a pie chart with a custom color palette?
You want a pie chart with slices colored purple, orange, and teal. Which code produces this?
Attempts:
2 left
💡 Hint
Use the correct parameter name and provide one color per slice.
✗ Incorrect
Option A uses the correct 'colors' parameter with three colors matching three slices.
🚀 Application
expert3:00remaining
How to create a pie chart with alternating slice colors?
You want a pie chart with 6 slices where colors alternate between 'red' and 'blue'. Which code creates this pattern?
Attempts:
2 left
💡 Hint
Use a list comprehension to generate the alternating colors list.
✗ Incorrect
Option B dynamically creates a list of 6 colors alternating red and blue, matching slice count.