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

Q/ Write python code:

  1. Learning Goals
  1. Apply the computing concepts of variousdata structuresto solve problems that analyze data
  2. Design test cases to better understand WHAT the functions are supposed to do
  3. Outline the design of your solution to describe the computations and computational steps
  4. Use the design and the test cases to implement, test, debug, and finish your Python program
  5. Verify and fix the coding style.
  1. BEFORE you start your design:
    1. Write thefunction signatures(or header) as given in the problem description
    2. 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
  1. Write THREE TEST CASES at the end of the Python module in a new function namedmain()
  1. Write thedocstringfor themain()function. Note that it doesn't have parameters or

return value.

  1. Definelocalvariables to store theinput values
  2. 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!