Complete the code to import the matplotlib plotting library.
import [1] as plt
We import matplotlib.pyplot as plt to create plots.
Complete the code to create a bar chart for categories and their counts.
categories = ['A', 'B', 'C'] counts = [10, 15, 7] plt.[1](categories, counts) plt.show()
The bar function creates bar charts, which are good for categorical data.
Fix the error in the code to label the x-axis with category names.
plt.bar([1, 2, 3], [5, 7, 3]) plt.xticks([1, 2, 3], [1]) plt.show()
The xticks function sets the labels on the x-axis. We want to label the bars with category names.
Fill both blanks to create a horizontal bar chart with labels and title.
plt.[1](counts, categories) plt.xlabel('[2]') plt.title('Category Counts') plt.show()
barh creates horizontal bars. The x-axis label should describe the counts.
Fill all three blanks to create a pie chart with labels and percentage display.
plt.[1](counts, labels=[2], autopct='[3]') plt.title('Category Distribution') plt.show()
The pie function creates pie charts. Labels are category names. autopct formats percentages.
