Skip to main contentSkip to solution

Consider the following command:

plt.hist(data, bins =10, color = 'red', edgecolor = 'blue')

What bins=10 specify?

Solution

✅ Correct Option: 3

In plt.hist(), an integer value for bins sets the number of equal-width intervals. Matplotlib takes the range from the minimum to the maximum of the data and divides it into 10 equal-width bins. Each bar's height shows how many data points fall in that bin.


Option 1: bins does not filter or count data points. It only sets the number of intervals.

Option 2: Colour is set by color='red', which gives all bars one colour.

Option 4: Bar outlines are set by edgecolor='blue', which applies to every bar, not just the 10th.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question