Question: In a file named histogram.py , implement the function histogram. The function will take two input parameters: ( 1 ) a list of dictionaries, and
In a file named histogram.py implement the function histogram. The function will take two input parameters: a list of dictionaries, and a string. The string will indicate what attribute will be plotted. You can also assume that the string provided is a key in all dictionaries in the list of dictionaries. The function will go through all students and store the number of students that are at each level of the attribute. For example, if the attribute is School it will store the number of students for each school. For numerical values eg Age you need to define intervals between and the maximum value of the attribute. Note that you do not know in advance which values will be there. This data will then be used to plot a histogram. The function will plot and show the histogram. The function will return if the attribute is categorical School and the maximum value for the given attribute if it is numerical.
Note: You have both numerical and string attributes. As hist only works with numerical values, you cannot use this function. You are required to use the function bar from Matplotlib.pyplot. You are not allowed to use hist.
Tests:
testshow testhistogram.histogramtestcase
testxlabel testhistogram.histogramtestcase
testylabel testhistogram.histogramtestcase
testtitle testhistogram.histogramtestcase
testbar testhistogram.histogramtestcase
testfigure testhistogram.histogramtestcase
testreturn testhistogram.histogramtestcase
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
