Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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 ueStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started