Bird
0
0

What will be the output type of the variable img after running this code?

medium📝 Predict Output Q13 of 15
Matplotlib - Image Display
What will be the output type of the variable img after running this code?
import matplotlib.pyplot as plt
img = plt.imread('sample.png')
AA NumPy array representing the image pixels
BA file path string to the image
CA matplotlib figure object
DA Python list of image filenames
Step-by-Step Solution
Solution:
  1. Step 1: Understand what plt.imread() returns

    This function reads an image file and returns its pixel data as a NumPy array.
  2. Step 2: Eliminate other options

    The variable is not a string, figure, or list but an array of pixel values.
  3. Final Answer:

    A NumPy array representing the image pixels -> Option A
  4. Quick Check:

    imread output = NumPy array [OK]
Quick Trick: imread returns pixel data as NumPy array [OK]
Common Mistakes:
  • Thinking it returns a file path or string
  • Confusing image data with plot objects
  • Assuming it returns a list instead of array

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes