Question: Problem 7 : Frequency Distribution In this problem, we will create a function named freq _ dist ( ) that creates a frequency distribution based
Problem : Frequency Distribution
In this problem, we will create a function named freqdist that creates a frequency distribution based on the
elements of a list. The function will accept a list of values as its input and will return two lists. One returned list will contain
the unique values found in the argument list, while the second list will contains counts of the number of times each of the
unique values occurred. For example: If mylist then
freqdistmylist should return the following tuple:
Define a function named freqdist with a single parameter x which is expected to be a list. This function should
return two lists. You can name these lists whatever you like, but for the sake of discussion, let's call them values and
counts.
The list values should be a sorted list of unique values appearing in x You can and should use the function
you wrote in Problem to create this list.
The list counts should be a list of integers. Each integer should be a count of the number of times a particular
value in values appears in x
An outline of this function is provided below:
Find the list of unique values, referred to above as values.
Create an empty list for counts.
Loop over values. Each time the loop executes, you should count the number of times the current element of
values appears in the list x appending the result to the counts list. I recommend using the counts list
method for this although you could also perform this using a second loop
Return the two lists values and counts.
We will now test the freqdist function. Create a new code cell to perform the steps below.
Create the list shown below:
grades ADACBFADC
BFACBABBC
BFDDACBBD
Call the freqdist function on this list. Display the resulting lists with messages formatted as shown below. Match
the formatting exactly. The lists displayed should be leftaligned.
Unique Values: xxxx
Frequencies: xxxx
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
