Question: USING PYTHON 3: I always rate my answer. the program need a main function Program 4: Word Frequencies (20 pts) 1. Use a text editor

USING PYTHON 3: I always rate my answer. the program need a main function

Program 4: Word Frequencies (20 pts) 1. Use a text editor to create a text file (ex: myPaper.txt) It should contain at least 2 paragraphs with around 200 or more words. 2. Write a Python program (HW19.py) that asks the user to provide the name of the text file reads from their text file NOTE: (do NOT use redirection, but rather write your program so that it ONLY works if it reads from the file whose name was entered by the user. 3. Your program will produce a dictionary of words with the number of times each occurs. The keys will be the words, and the values will be the number of times each word occurs in the text. The report should be an ALPHABETIZED output table, listing the word and the number of occurrences. NOTES: The input sequence can be words, numbers or any other immutable Python object, suitable for a dict key. Ignore case - apple is the same as Apple is the same as APPLE, etc The program could read a line of input from the file, discard all punctuation and break the line into separate words . Put the words into a dict. The first time a word is seen, the frequency is 1. Each time the word is seen again, increment the frequency. NOTE: you are REQUIRED to use the dictionary class for this assignment. Produce a frequency table. To alphabetize the frequency table, extract just the keys and sort them. This sorted sequence of keys can be used to extract the counts from the dict Make sure that your output (the table) is formatted so that the columns are aligned, and so that there are titles for each column Be sure to modularize your code , using functions appropriately. Your main program should be clean and easy to read, calling the functions with meaningful names. Pass parameters - do not use global variables. Be sure to avoid using global variables

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!