Question: Q/ Write python code: Learning Goals Apply the computing concepts of various data structures to solve problems that analyze data Design test cases to better
- Learning Goals
- Apply the computing concepts of variousdata structuresto solve problems that analyze data
- Design test cases to better understand WHAT the functions are supposed to do
- Outline the design of your solution to describe the computations and computational steps
- Use the design and the test cases to implement, test, debug, and finish your Python program
- Verify and fix the coding style.
- BEFORE you start your design:
- Write thefunction signatures(or header) as given in the problem description
- Write adocstringthat describes
- WHAT the function does
- WHAT parameters the function has and their data types
- WHAT the function returns: data type of return value
- Write THREE TEST CASES at the end of the Python module in a new function namedmain()
- Write thedocstringfor themain()function. Note that it doesn't have parameters or
return value.
- Definelocalvariables to store theinput values
- Writefunction callswith input values as arguments and assign the return value toreturn valuevariable
d.Test cases are chosen as follows:
- FIRST test case has a dictionary value you define in main().
- SECOND test case uses the filesimple.txtdirectory. To create the dictionary test case value, callword_histogram('simple.txt')first and then call the function you are testing.
- THIRD test case uses the filescarlet.txttext file. Similar to the SECOND test case, callword_histogram('scarlet.txt')first to get the dictionary test case value you'll pass to the call to the function you are testing.
Computational Problems
Problem 1
Define a functionlongest_words(histogram)that finds and returns a list of the longest unique words corresponding to the keys in the dictionary histogram
histogram: dictionary
keys: strings
values: non-negative integers
Returns: list of strings of the same size
Testing requirements: To test the implementation of this function you must use three test cases as described at Guideline #3
Problem 2
Define a functionmost_popular_words(file_name)that finds and returns a list of unique words that have the highest frequency in a text file.
file_name: name of a text file in current directory
Returns: list of strings
Testing requirement: To test the implementation of this function you must use three test cases as described at Guideline #3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
