Bird
0
0

Identify the error in this code that customizes a Seaborn boxplot:

medium📝 Debug Q6 of 15
Matplotlib - Seaborn Integration
Identify the error in this code that customizes a Seaborn boxplot:
import seaborn as sns
import matplotlib.pyplot as plt

sns.boxplot(data=sns.load_dataset('iris'), x='species', y='sepal_length')
plt.title = 'Sepal Length by Species'
plt.show()
AThe dataset 'iris' is not available in seaborn
Bplt.title is assigned a string instead of called as a function
Cplt.show() is missing parentheses
Dsns.boxplot requires a hue parameter
Step-by-Step Solution
Solution:
  1. Step 1: Check plt.title usage

    plt.title is a function and must be called with parentheses, not assigned a string.
  2. Step 2: Verify other parts

    sns.boxplot works without hue, plt.show() is correctly called, and 'iris' dataset is available.
  3. Final Answer:

    plt.title is assigned a string instead of called as a function -> Option B
  4. Quick Check:

    plt.title must be called, not assigned = D [OK]
Quick Trick: Call plt.title() with parentheses to set plot title [OK]
Common Mistakes:
  • Assigning string to plt.title instead of calling it
  • Adding unnecessary hue parameter
  • Forgetting parentheses in plt.show()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes