Bird
0
0

What will this code display on a Raspberry Pi?

medium📝 Predict Output Q5 of 15
Raspberry Pi - Display and Output
What will this code display on a Raspberry Pi?
import matplotlib.pyplot as plt
plt.barh(['X', 'Y', 'Z'], [10, 15, 7])
plt.xlabel('Scores')
plt.ylabel('Groups')
plt.show()
AA vertical bar chart with groups X, Y, Z and their scores
BA horizontal bar chart with groups X, Y, Z and their scores
CA line chart connecting points (X,10), (Y,15), (Z,7)
DAn error because plt.barh is not a valid function
Step-by-Step Solution
Solution:
  1. Step 1: Understand plt.barh()

    plt.barh() creates a horizontal bar chart with given categories and values.
  2. Step 2: Analyze the code

    Groups X, Y, Z are on y-axis with scores 10, 15, 7 on x-axis.
  3. Step 3: Confirm labels and display

    Labels for x and y axes are set correctly and plt.show() displays the plot.
  4. Final Answer:

    A horizontal bar chart with groups X, Y, Z and their scores -> Option B
  5. Quick Check:

    plt.barh makes horizontal bars [OK]
Quick Trick: plt.barh = horizontal bars, plt.bar = vertical bars [OK]
Common Mistakes:
MISTAKES
  • Confusing horizontal and vertical bar charts
  • Thinking plt.barh is invalid
  • Expecting line chart output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes