0
0
Data Analysis Pythondata~10 mins

Histograms in Data Analysis Python - Interactive Code Practice

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.

Data Analysis Python
import [1] as plt
Drag options to blanks, or click blank then click option'
Anumpy
Bmatplotlib.pyplot
Cpandas
Dseaborn
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong library like pandas or numpy for plotting.
Forgetting to import matplotlib.pyplot.
2fill in blank
medium

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

Data Analysis Python
data = [1, 2, 2, 3, 3, 3, 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 or scatter instead of hist for histograms.
Forgetting to call plt.show() to display the plot.
3fill in blank
hard

Fix the error in the code to set the number of bins to 5 in the histogram.

Data Analysis Python
data = [1, 2, 2, 3, 3, 3, 4]
plt.hist(data, bins=[1])
plt.show()
Drag options to blanks, or click blank then click option'
A5
B5.0
C'5'
Dbins=5
Attempts:
3 left
💡 Hint
Common Mistakes
Passing bins as a string like '5' instead of an integer.
Using an expression like bins=5 inside the argument list.
4fill in blank
hard

Fill both blanks to create a histogram with 4 bins and set the color to blue.

Data Analysis Python
plt.hist(data, bins=[1], color=[2])
plt.show()
Drag options to blanks, or click blank then click option'
A4
B'red'
C'blue'
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using color without quotes.
Setting bins to a string instead of a number.
5fill in blank
hard

Fill all three blanks to create a histogram with 6 bins, green color, and add a title 'My Histogram'.

Data Analysis Python
plt.hist(data, bins=[1], color=[2])
plt.title([3])
plt.show()
Drag options to blanks, or click blank then click option'
A6
B'green'
C'My Histogram'
D'Histogram'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around color or title strings.
Using wrong number of bins.