Question: Function 2 : histogram implement the function histogram. The function will take two input parameters: ( 1 ) a list of dictionaries, and ( 2
Function : histogram
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 provide is a key in all dictionaries in the list of dictionaries.
The function will go through all characters and store the number of characters that are at each level of the attribute. For example, if the attribute is Occupation it will store the number of characters for each occupation. For numeric values eg Stamina, Health, etc. 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 eg Occupation and the maximum value for the given attribute if it is numerical.
Note: You have both numerical int and float 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.
Examples
histogramoccupation: AT "Stamina": occupation: DB "Stamina": occupation: AT "Stamina": "Occupation"
histogramOccupation: AT "Strength": Occupation: DB "Strength: Occupation: AT "Strength": Occupation: AT "Strength": "Strength"
histogramWeapon: "Staff", "Personality": Weapon: "Club", "Personality": Weapon: "Dagger", "Personality": Weapon: "Dagger", "Personality": Weapon: "Staff", "Personality": Weapon: "Dart", "Personality": "Personality"
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
