Question: Write a function getStats(fname) that determines the following statistics for the input file, fname, and write the results to the text file, FileStats.txt. ? Number

Write a function getStats(fname) that determines the following statistics for the input file,

fname, and write the results to the text file, FileStats.txt.

? Number of occurrences of each day of the week in the file.

? Number of lines (determined by end of line character " ")

? Number of words

? Numbers of characters (excludes spaces between words)

The output from getStats() should

? print the message 'To view the results go to FileStats.txt'

? return 'Thanks for using the getStats() function'

Write a function getStats(fname) that determines the following statistics for the input

To view the contents of FileStats.txt, go to the folder where your program is saved and, double click on FileStats.txt. Your file should be formatted as shown below. FileStats.txt Statistics for Emma. txt created by D. Kalayta Monday occurs 2 times Tuesday occurs 7 times Wednesday occurs 2 times Thursday occurs 0 times Friday occurs 3 times Saturday occurs 7 times Sunday occurs 2 times There are 13, 981 lines There are 160,364 words There are 738, 135 characters (excludes spaces between words) The function should be able to handle any file the user specifies when calling the function. I will test with a different file and I expect to see the name of that file in the first line of FileStats.txt

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!