Which of the following histogram functions are correct?
import matplotlib.pyplot as plt
(A). plt.bar( )
(B). plt.hist( )
(C). plt.plot(kind= 'hist')
(D). plt.plot(kind = 'histogram')
Which of the following histogram functions are correct?
import matplotlib.pyplot as plt
(A). plt.bar( )
(B). plt.hist( )
(C). plt.plot(kind= 'hist')
(D). plt.plot(kind = 'histogram')
Solution
✅ Correct Option: 3
plt.hist() is matplotlib's dedicated histogram function. The plot type given as kind='hist' is also treated as a histogram, so (B) and (C) are the correct pair.
(A): plt.bar() draws a bar chart, where each bar is a category with a given height. A histogram instead bins continuous data into intervals.
(D): 'histogram' is not a valid plot kind. The accepted string is 'hist'.
Remember that bar charts have gaps between bars and histograms do not.
Related questions:
2025: 30 May Shift 2
2026: 21 May Shift 1
2026: 13 May Shift 2
