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
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 wcpy and must be run like so:
python wcpy 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,whenyourprogramisrunwiththisfilepython wcpy healthyeating.txt theoutputoftheprogramshouldbeintheballparkoflines: unique: words: chars: 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 wcpy healthyeating.txt will print:
lines: unique: words: chars:
Most frequent word:and times Less frequent word:People times
Again, your output may be slightly different than this depending on what you consider a word. eg 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
