Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong library like pandas or numpy for plotting.
Forgetting to import matplotlib.pyplot.
✗ Incorrect
We use matplotlib.pyplot to create histograms in Python.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using plot or scatter instead of hist for histograms.
Forgetting to call plt.show() to display the plot.
✗ Incorrect
The hist function creates a histogram from data.
3fill in blank
hardFix 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'
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.
✗ Incorrect
The bins parameter expects an integer number, not a string or expression.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using color without quotes.
Setting bins to a string instead of a number.
✗ Incorrect
We set bins to 4 and color to 'blue' as a string to customize the histogram.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around color or title strings.
Using wrong number of bins.
✗ Incorrect
Set bins to 6, color to 'green', and title to 'My Histogram' as a string.