Question: In Python Write a function called generate frequency table(filename) which accepts the name of a text file and returns a dictionary containing the frequency of

 In Python Write a function called generate frequency table(filename) which accepts

In Python

Write a function called generate frequency table(filename) which accepts the name of a text file and returns a dictionary containing the frequency of all the letters that appear in the file. For purposes of the frequency count, any non-letter characters are ignored, and the difference between upper and lower case letters is ignored (i.e., treat all letters as lower case) You may wish to break the task up further and use several smaller functions to achieve this task. For example, it might be convenient to have functions to perform each of the following tasks . read and return the contents of a text file .remove all non-letter characters from a given string .perform a frequency count of letters in a given string Hint: The string class has an attribute called ascii_letters which is a string containing all the letters. You can access that string using import string Letters - string.ascii_letters https://coderunner2.auckland.ac.nz/moodle/pluginfile.php/29330/question/questiontext/120411/7/25822/test 01.txt https://coderunner2.auckland.ac.nz/moodle/pluginfile.php/29330/question/questiontext/120411/7/25822/test 02.txt For example: Test Result data generate_frequency_table('test 01.txt') print(data'a' 2, 's': 1, 'm': 1, 'l': 3, 't': 2, 'e': 2, 'x': 1, 'f': 1, 'i': 1}) ue data generate_frequency_table('test_02.txt') print(data_ {'a': 4, 's': 3, 'm': 1, 'l': 5, 't": 5, "e": 4, 'x': 1, 'f': 1, 'i': 3, 'h': 4, o': 3, 'n: 3, 'p':1, u' 2, c'13 Tr ue

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!