• +1 315 683 4089
  • support@homework-hub.com
  • Opening Hours: All Time

Call Now+1 315 683 4089

Send Messagesupport@homework-hub.com

Our Location211 Ronad, California, Us

Test File
By: Sebastian

Write Python programs that involve files, classes and objects. The programs involving files should have most of the file processing activities encapsulated in a separate function. Each class definition with its member variables and methods should be in its own file

Write Python programs that involve files, classes and objects. The programs involving files should have most of the file processing activities encapsulated in a separate function. Each class definition with its member variables and methods should be in its own file.

1.    Input text data from a file: The main program should allow the user to choose a data file. The program should then open the file for reading. Input the contents of the file into a single string S, and then close the file..
Your main program should next have the user input a single word W (e.g. “who”). The program should call the function countWord(S,W), which will return the number of occurrences of word W in string S. The count should be case insensitive, so convert string S and word W to lower case before performing the word count. Note that W sometimes may be part of a longer word, which increases the count.
Output the word (in lower-case) along with the search frequency. For each of the files listed below, run your program for all of the following words (one word at a time):
Words:         the,   and,   he,   she,   his,   her
Files:    (a)    DeclarationOfIndependence.txt
(b)    PrideAndPrejudiceCh1.txt
(c)    SilverBlaze.txt

2.    More text file analysis: The main program should allow the user to choose a data file. The program should then open the file for reading. Input the contents of the file into a single string S, and then close the file.
Your main program should next have the user input a single word W with no repeating characters (e.g. “abcXYZ”). The program should call the function countChars(S,W). This function will return a list F containing frequencies for each character in W. The frequencies in the list should appear in the same order as the characters in W.
The counts should be case insensitive, so convert string S and word W to lower case before performing the character counts.
Output each character in word W paired with the frequency for that character. Run your program for the following test cases:
(a)    File:  RoadNotTaken.txt            Word: “TRaeiou”
(b)    File:  IfByKipling.txt            Word: “YFaeiou”
(c)    File:  Jabberwocky.txt            Word: “JBaeiou”

Completed Orders
Homework Hub has helped 642,704 students.