Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the matplotlib library for plotting.
Matplotlib
import [1] as plt
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong library like pandas or numpy for plotting.
Forgetting to import pyplot specifically.
✗ Incorrect
We use matplotlib.pyplot as the standard library to create scatter plots in Python.
2fill in blank
mediumComplete the code to create a scatter plot with x and y data.
Matplotlib
plt.[1](x, y) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
plt.plot which draws lines, not scatter points.Using bar or hist which are for different chart types.
✗ Incorrect
The scatter function draws a scatter plot showing points for x and y values.
3fill in blank
hardFix the error in the code to show the plot correctly.
Matplotlib
plt.scatter(x, y)
plt.[1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
plt.plot() or plt.draw() which do not display the plot window.Forgetting to call any function to display the plot.
✗ Incorrect
The plt.show() function displays the plot window so you can see the scatter plot.
4fill in blank
hardFill both blanks to create a scatter plot with labels for axes.
Matplotlib
plt.scatter(x, y) plt.xlabel([1]) plt.[2]('Y Axis') plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
plt.title instead of plt.ylabel for y-axis label.Not putting quotes around the axis label text.
✗ Incorrect
Use plt.xlabel('X Axis') and plt.ylabel('Y Axis') to label the axes of the scatter plot.
5fill in blank
hardFill in the blanks to create a scatter plot with title and grid.
Matplotlib
plt.scatter(x, y) plt.title([1]) plt.grid([2]) plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes for the title string.
Passing False to grid when you want to show grid lines.
✗ Incorrect
Set the plot title with plt.title('My Scatter Plot') and enable grid lines with plt.grid(True).