Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the plotting library.
Matplotlib
import [1] as plt
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing numpy or pandas instead of matplotlib.pyplot
Using seaborn without importing matplotlib.pyplot
✗ Incorrect
We use matplotlib.pyplot as the standard library for plotting in Python.
2fill in blank
mediumComplete the code to create a simple line plot of data.
Matplotlib
plt.[1]([1, 2, 3, 4], [10, 20, 25, 30]) plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using scatter instead of plot for line graphs
Using hist which is for histograms
✗ Incorrect
The plot function draws a line plot connecting points.
3fill in blank
hardFix the error in the code to display a histogram of data.
Matplotlib
data = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4] plt.hist([1]) plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing plt or hist instead of the data list
Passing a string instead of the variable
✗ Incorrect
The histogram function needs the data list as input to plot the frequency.
4fill in blank
hardFill both blanks to create a scatter plot with labels.
Matplotlib
plt.[1](x, y) plt.[2]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using plot instead of scatter for points
Forgetting to call show()
✗ Incorrect
Use scatter to plot points and show to display the plot.
5fill in blank
hardFill all three blanks to create a bar chart with labels and title.
Matplotlib
plt.bar([1], [2]) plt.xlabel([3]) plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping categories and values
Not labeling the axes
✗ Incorrect
Bar charts need categories and values. Labels help explain the axes.