Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the seaborn library as sns.
Matplotlib
import [1] as sns
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing matplotlib instead of seaborn.
Using wrong alias like 'sb' instead of 'sns'.
✗ Incorrect
Seaborn is the library used for KDE plots, so we import it as sns.
2fill in blank
mediumComplete the code to create a KDE plot of data1 with shading.
Matplotlib
sns.kdeplot([1], shade=True)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using data2 instead of data1.
Passing a wrong variable name.
✗ Incorrect
We want to plot the KDE of data1, so we pass data1 to sns.kdeplot.
3fill in blank
hardFix the error in the code to overlay KDE plots of data1 and data2 on the same axes.
Matplotlib
sns.kdeplot(data1, shade=True) sns.kdeplot([1], shade=True)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Plotting data1 twice.
Using a variable not defined.
✗ Incorrect
To overlay, plot data1 first, then data2 on the same axes.
4fill in blank
hardFill both blanks to create KDE plots of data1 and data2 with different colors.
Matplotlib
sns.kdeplot([1], shade=True, color='blue') sns.kdeplot([2], shade=True, color='red')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping data1 and data2.
Using the same color for both plots.
✗ Incorrect
Use data1 for the blue plot and data2 for the red plot to distinguish them.
5fill in blank
hardFill all three blanks to create KDE plots of data1 and data2 with labels and a legend.
Matplotlib
sns.kdeplot([1], shade=True, label=[2], color=[3]) sns.kdeplot(data2, shade=True, label='Data 2', color='red') plt.legend()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to add labels.
Not calling plt.legend() to show the legend.
✗ Incorrect
Plot data1 with label 'Data 1' and color blue, then data2 with label 'Data 2' and color red, then show legend.