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 as sns
Importing pandas or numpy instead of seaborn
✗ Incorrect
Seaborn is imported using import seaborn as sns to use its plotting functions.
2fill in blank
mediumComplete the code to create a seaborn scatter plot using the 'tips' dataset.
Matplotlib
sns.scatterplot(data=tips, x='total_bill', y=[1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'size' or 'day' which are not numeric for y-axis
Using 'time' which is categorical
✗ Incorrect
The y-axis should be the 'tip' column to plot tip amounts against total bill.
3fill in blank
hardFix the error in the code to set the plot title using Matplotlib.
Matplotlib
plt.[1]('Scatter plot of Total Bill vs Tip')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using plt.xlabel or plt.ylabel instead of plt.title
Using plt.legend which is for legends
✗ Incorrect
The function plt.title() sets the title of the plot.
4fill in blank
hardFill both blanks to change the x-axis label and y-axis label using Matplotlib.
Matplotlib
plt.xlabel([1]) plt.ylabel([2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using labels without quotes
Mixing up x and y labels
✗ Incorrect
Use plt.xlabel and plt.ylabel to set axis labels with descriptive text.
5fill in blank
hardFill all three blanks to customize the plot: set figure size, add grid, and show the plot.
Matplotlib
plt.figure(figsize=[1]) plt.grid([2]) plt.[3]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing grid as string instead of boolean
Forgetting plt.show() to display plot
Using incorrect figure size format
✗ Incorrect
Use plt.figure(figsize=(8,6)) to set size, plt.grid(True) to add grid, and plt.show() to display the plot.