Question: 4 . 1 Task Create a program that reads a filename from the command line and prints the number of unique words, total number of

4.1 Task
Create a program that reads a filename from the command line and prints the number of unique words, total number of words (not unique), characters (includ- ing spaces) and lines in that file. It must be called wc.py and must be run like so:
python wc.py filename
where filename is the actual name of the file to read.
As an example, download this sample file: heaalthyeating.txt. you can use this to test. I may run it with a different file.
Then,whenyourprogramisrunwiththisfile(python wc.py healthyeating.txt), theoutputoftheprogramshouldbeintheballparkoflines:42, unique:429, words:819, chars:4 The numbers may vary a bit, but not a lot.
Your program must print the most common and least common word. You must usedictionariesforthis.Usingthehealthyeating.txtfile,python wc.py healthyeating.txt will print:
lines:42, unique:429, words:819, chars:4878
Most frequent word:and (33 times), Less frequent word:People (1 times).
Again, your output may be slightly different than this depending on what you consider a word. (e.g. you turn all words to lowercase or something like that).

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 Databases Questions!