On Unix/Linux systems a utilit

Anonymous
timer Asked: Mar 28th, 2016

Question description

On Unix/Linux systems a utility called wc exists to analyze a file and determine the number of lines, words, and characters present. This project involves writing your own version of this utility using Python.

 First of all, create a text file (extension needs to be .txt) containing multiple lines of various number of words and characters. This needs to be a simple text file (i.e., not data format like .docx for MS Word). Be sure to put a blank character between the words. Some lines should only contain a return character (no words or blank characters). This file should be placed in the same folder as the program you will write.

 Your program needs to ask the user to enter the filename containing the lines of words. Note: use the file you created above for your test case. Then your program needs to count the number of lines, words, and characters in the file. Blank characters are not to be included in the character count. Lines containing just a return character are to be ignored.

 The number of lines, words, and characters are to be displayed (with proper labels) one to a line, right justified so that the numeric values line up from the right side.

 Extra Credit – up to 15 points:

o As an aid in debugging, write a function called writeDetails based on the following

specifications:

 The formal parameters must contain the name of the output file, the line

number, actual line contents (without the ending carriage return), words on that line, number of words on that line, running total of the number of words, number of characters on that line, and running total of the number of characters.

 writeDetails is to write to an output file the items sent into the function.

 The program must ask the user (in main) the name of the output file, which is

to be passed into writeDetails with the other parameters.

 Items are to be written to the output file for each line of the input file

processed.

 Create an IPO chart to design your solution before writing your program.


Tutor Answer

(Top Tutor) Studypool Tutor
School: UC Berkeley
Studypool has helped 1,244,100 students
flag Report DMCA
Similar Questions
Hot Questions
Related Tags

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors