Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a boxplot using seaborn.
Data Analysis Python
import seaborn as sns import matplotlib.pyplot as plt data = sns.load_dataset('tips') sns.boxplot(x='day', y='total_bill', data=[1]) plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the seaborn module instead of the dataset.
Passing the plotting module plt instead of the dataset.
Using the dataset name 'tips' as a string instead of the variable.
✗ Incorrect
The 'data' variable holds the dataset to plot. Passing it to the 'data' parameter is required.
2fill in blank
mediumComplete the code to create a violinplot grouped by 'sex'.
Data Analysis Python
import seaborn as sns import matplotlib.pyplot as plt data = sns.load_dataset('tips') sns.violinplot(x='day', y='total_bill', hue=[1], data=data) plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'time' or 'smoker' instead of 'sex' for grouping.
Not passing the column name as a string.
✗ Incorrect
The 'hue' parameter groups the plot by the 'sex' column.
3fill in blank
hardFix the error in the code to plot a boxplot with seaborn.
Data Analysis Python
import seaborn as sns import matplotlib.pyplot as plt data = sns.load_dataset('tips') sns.boxplot(x='day', y='total_bill', data=[1]) plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the string 'tips' instead of the variable.
Passing the seaborn or matplotlib modules instead of the dataset.
✗ Incorrect
The variable 'data' holds the dataset. Using 'data' fixes the error.
4fill in blank
hardFill both blanks to create a violinplot with split by smoker status.
Data Analysis Python
import seaborn as sns import matplotlib.pyplot as plt data = sns.load_dataset('tips') sns.violinplot(x=[1], y='total_bill', hue=[2], data=data, split=True) plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the x and hue parameters.
Using 'sex' or 'time' instead of 'smoker' for hue.
✗ Incorrect
The x-axis is 'day' and the hue is 'smoker' to split the violinplot by smoker status.
5fill in blank
hardFill all three blanks to create a boxplot grouped by day and colored by time.
Data Analysis Python
import seaborn as sns import matplotlib.pyplot as plt data = sns.load_dataset('tips') sns.boxplot(x=[1], y=[2], hue=[3], data=data) plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up x and y parameters.
Using 'sex' instead of 'time' for hue.
Not passing column names as strings.
✗ Incorrect
The x-axis is 'day', y-axis is 'total_bill', and hue groups by 'time' (Lunch or Dinner).