0
0
Matplotlibdata~10 mins

Why histograms show distributions in Matplotlib - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the library needed to create histograms.

Matplotlib
import [1] as plt
Drag options to blanks, or click blank then click option'
Apandas
Bseaborn
Cmatplotlib.pyplot
Dnumpy
Attempts:
3 left
💡 Hint
Common Mistakes
Importing numpy instead of matplotlib.pyplot
Importing pandas which is for data frames
Importing seaborn which is a different plotting library
2fill in blank
medium

Complete the code to create a histogram of the data list.

Matplotlib
data = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]
plt.[1](data)
plt.show()
Drag options to blanks, or click blank then click option'
Ahist
Bplot
Cscatter
Dbar
Attempts:
3 left
💡 Hint
Common Mistakes
Using plot which makes a line graph
Using scatter which makes a scatter plot
Using bar which makes bar charts but not histograms
3fill in blank
hard

Fix the error in the code to correctly label the x-axis.

Matplotlib
plt.hist(data)
plt.xlabel([1])
plt.show()
Drag options to blanks, or click blank then click option'
A'Values'
Bxlabel
Cx_label
DValues
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names without quotes
Using incorrect function names
Forgetting quotes around label text
4fill in blank
hard

Fill both blanks to create a histogram with 5 bins and a title.

Matplotlib
plt.hist(data, bins=[1])
plt.title([2])
plt.show()
Drag options to blanks, or click blank then click option'
A5
B'Data Distribution'
C'Histogram'
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using too many bins like 10
Not putting the title in quotes
Confusing bins with title
5fill in blank
hard

Fill all three blanks to create a histogram with green color, 8 bins, and x-axis label 'Scores'.

Matplotlib
plt.hist(data, bins=[1], color=[2])
plt.xlabel([3])
plt.show()
Drag options to blanks, or click blank then click option'
A8
B'green'
C'Scores'
D'blue'
Attempts:
3 left
💡 Hint
Common Mistakes
Using color without quotes
Using numbers instead of strings for labels
Mixing up color names