Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to plot a histogram of the 'age' column from the DataFrame df.
Pandas
df['age'].[1](bins=10)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'plot' instead of 'hist' which creates a line plot by default.
Using 'scatter' which is for scatter plots, not histograms.
✗ Incorrect
The hist method creates a histogram plot of the data.
2fill in blank
mediumComplete the code to plot a histogram with 20 bins for the 'salary' column in DataFrame df.
Pandas
df['salary'].hist([1]=20)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'range' which defines the interval but not the number of bins.
Using 'width' or 'height' which are not parameters for histograms.
✗ Incorrect
The bins parameter controls the number of bins in the histogram.
3fill in blank
hardFix the error in the code to plot a histogram of 'height' with 15 bins.
Pandas
df['height'].hist(bins=[1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing '15' as a string instead of integer 15.
Passing a range object which is not accepted.
✗ Incorrect
The bins parameter expects an integer, not a string or range.
4fill in blank
hardFill both blanks to create a histogram of 'weight' with 12 bins and a blue color.
Pandas
df['weight'].hist(bins=[1], color=[2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using color without quotes.
Using a string for bins instead of a number.
✗ Incorrect
Use bins=12 for 12 bins and color='blue' to set the bar color.
5fill in blank
hardFill all three blanks to create a histogram of 'score' with 8 bins, green color, and transparency set to 0.5.
Pandas
df['score'].hist(bins=[1], color=[2], alpha=[3])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using alpha as a string instead of a number.
Using wrong number of bins.
✗ Incorrect
Set bins=8, color='green', and alpha=0.5 for transparency.