Posted: November 21st, 2014

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”

PLACE THIS ORDER OR A SIMILAR ORDER WITH US TODAY AND GET AN AMAZING DISCOUNT 🙂

Expert paper writers are just a few clicks away

Place an order in 3 easy steps. Takes less than 5 mins.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00
Live Chat+1-631-333-0101EmailWhatsApp