Complete the code to import the matplotlib pyplot module with the common alias.
import matplotlib.[1] as plt
The matplotlib module for plotting is called pyplot. We import it as plt to use its plotting functions easily.
Complete the code to plot a line graph using x and y data.
plt.[1](x, y)
plt.show()The plot function draws a line graph connecting points from x and y data.
Fix the error in the code to add an annotation at point (2, 4) with text 'Peak'.
plt.annotate('Peak', xy=(2, 4), xytext=[1], arrowprops=dict(facecolor='black')) plt.show()
The xytext parameter expects a tuple for the text position, so (3, 5) is correct.
Fill both blanks to highlight the region between x=1 and x=3 with a light blue color.
plt.fill_between(x, y, where=(x [1] 1) & (x [2] 3), color='lightblue', alpha=0.5) plt.show()
To highlight between x=1 and x=3, we select points where x is greater or equal to 1 and less or equal to 3.
Fill all three blanks to create a dictionary comprehension that maps each word to its length only if the length is greater than 3.
lengths = { [1]: [2] for [3] in words if len([3]) > 3 }The dictionary comprehension uses word as the key, len(word) as the value, and iterates over word in words. The condition filters words longer than 3 characters.