0
0
Matplotlibdata~10 mins

Why pie charts show proportions in Matplotlib - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a pie chart showing proportions of fruits.

Matplotlib
import matplotlib.pyplot as plt

sizes = [30, 45, 25]
labels = ['Apples', 'Bananas', 'Cherries']
plt.pie(sizes, labels=[1])
plt.show()
Drag options to blanks, or click blank then click option'
Alabels
Bcolors
Csizes
Dexplode
Attempts:
3 left
💡 Hint
Common Mistakes
Using the sizes list instead of labels for the labels parameter.
Confusing colors or explode parameters with labels.
2fill in blank
medium

Complete the code to add percentages on each pie slice.

Matplotlib
plt.pie(sizes, labels=labels, autopct=[1])
plt.show()
Drag options to blanks, or click blank then click option'
A'%s%%'
B'%d%%'
C'%.1f%%'
D'%%.1f'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '%d%%' which shows no decimal places.
Using incorrect format strings that cause errors.
3fill in blank
hard

Fix the error in the code to correctly display the pie chart with a shadow.

Matplotlib
plt.pie(sizes, labels=labels, autopct='%.1f%%', [1]=True)
plt.show()
Drag options to blanks, or click blank then click option'
Ashadow
Bshadows
Cshadowed
Dshow_shadow
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect parameter names like 'shadows' or 'shadowed'.
Trying to add shadow with unsupported parameters.
4fill in blank
hard

Fill both blanks to create a pie chart with exploded slices and a start angle.

Matplotlib
explode = ([1], [2], 0)
plt.pie(sizes, labels=labels, explode=explode, startangle=90)
plt.show()
Drag options to blanks, or click blank then click option'
A0.1
B0.2
C0
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using integers like 1 which explode slices too much.
Using negative numbers which cause errors.
5fill in blank
hard

Fill all three blanks to create a pie chart with colors, shadow, and percentage format.

Matplotlib
colors = ['gold', 'yellowgreen', [1]]
plt.pie(sizes, labels=labels, colors=colors, autopct=[2], [3]=True)
plt.show()
Drag options to blanks, or click blank then click option'
A'lightcoral'
B'%.0f%%'
Cshadow
D'blue'
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid color names or missing quotes.
Wrong format strings for autopct causing errors.
Incorrect parameter name for shadow.