Question: Write a PYTHON program that will use a dictionary that will determine how many times each letter in the alphabet occurs in a file. Suggested

Write a PYTHON program that will use a dictionary that will determine how many times each letter in the alphabet occurs in a file. Suggested flow: Create an empty dictionary. Prompt the user for a file name. Open the file for reading. Loop through the file line by line. Update the dictionary to be a a histogram of letter counts. (The letter A occurs 27 times, the letter B occurs 16 times, and so on). So if the character is not in the dictionary, put it there, with a value of 1. If it is, update its value incrementing it by 1. Display an informative barchart showing the letter counts. (This could be a fancy graph done with turtle graphics, or a display of printed asterisks. Suggestions...You could use the files readlines() function to read the entire file into a list of strings, and then process each string with a for loop. On the other hand, theres nothing wrong with processing the file as a series of lines of text, with a for-data-in-file loop. This is the prefered way in most cases - if a file is long, you don't want to load the entire file into memory at once. I suggest convert the string(s) to uppercase letters, and using string.isalpha( ) to determine if a character is a letter. Ignore non-alphabet characters.

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!