Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the matplotlib plotting library.
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 seaborn or numpy.
Forgetting to use the alias plt.
✗ Incorrect
We import matplotlib.pyplot as plt to create plots.
2fill in blank
mediumComplete the code to create a box plot of the data list.
Matplotlib
plt.[1](data) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using violinplot instead of boxplot.
Using hist or scatter which are different plot types.
✗ Incorrect
The boxplot function draws a box plot to show data distribution.
3fill in blank
hardFix the error in the code to create a violin plot of the data list.
Matplotlib
plt.[1](data) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using boxplot instead of violinplot.
Using plot or bar which do not create violin plots.
✗ Incorrect
The violinplot function draws a violin plot which shows data distribution shape.
4fill in blank
hardFill both blanks to create side-by-side box and violin plots for the same data.
Matplotlib
fig, ax = plt.subplots() ax.[1](data, positions=[1]) ax.[2](data, positions=[2]) plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using scatter or hist instead of violinplot for the second plot.
Not specifying positions to separate the plots.
✗ Incorrect
Use boxplot and violinplot methods on the same axes to compare plots side-by-side.
5fill in blank
hardFill all three blanks to create labeled box and violin plots with titles and axis labels.
Matplotlib
fig, ax = plt.subplots() ax.[1](data, positions=[1]) ax.[2](data, positions=[2]) ax.set_xticks([1, 2]) ax.set_xticklabels([[3]]) ax.set_title('Box vs Violin Plot') plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping boxplot and violinplot order.
Using wrong labels or mismatched labels for ticks.
✗ Incorrect
First create boxplot, then violinplot. Then label x-axis ticks with descriptive names.