Bird
0
0

Identify the error in this code snippet:

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

data = [1, 2, 3, 4, 5]
sns.barplot(data)
plt.show()
ASeaborn does not have barplot function
Bsns.barplot requires x and y arguments, not just data
Cplt.show() is missing parentheses
DData must be a DataFrame, not a list
Step-by-Step Solution
Solution:
  1. Step 1: Check sns.barplot usage

    sns.barplot needs x and y parameters or a DataFrame with specified columns.
  2. Step 2: Analyze given code

    Passing only a list without specifying x or y causes error.
  3. Final Answer:

    sns.barplot requires x and y arguments, not just data -> Option B
  4. Quick Check:

    sns.barplot needs x and y args [OK]
Quick Trick: Always provide x and y or a DataFrame to sns.barplot [OK]
Common Mistakes:
  • Passing only data list to sns.barplot
  • Forgetting plt.show() parentheses
  • Thinking barplot doesn't exist in Seaborn

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes