(Solved) : Write Python Program Reads Text File Counts Many Occurrences Character Text User May Ask P Q42684694 . . .

Write a PYTHON program that reads a text fileand
counts how many occurrences of each character are there in thetext. The user may ask the
program to ignore some characters and those to be ignored will alsobe specified in a file.
The program does the following:
1. Prompt the user for the name of the file that contains the textto be examined.
2. Ask the user if they want to ignore some characters. If the useranswers yes, the
program should ask for the name of the file containing the set ofcharacters to be
ignored from the frequency count.
3. Read all the characters from the file and build a Pythondictionary that contains each
character found in the file and relate it to an integer that tellshow many times that
character appeared in the file.
4. After processing the text file and building the dictionary, theprogram will print the
most frequent characters with a count of how many times they appearin the text le.
5. Will control the exceptions that may happen in the program, byusing the constructs
try and except.

Example output transcript of program (User input
is in italics.):
1. User provides the name of the file on which to count thecharacter occur-
rences:

What is the name of the file to be examined?
textfile.txt
Do you want to ignore some characters?
No
The most frequent character was the space with 30occurrences.

2. Users provides name of the input file and name of the file withto be
ignored characters:

What is the name of the file to be examined?
textfile.txt
Do you want to ignore some characters?
Yes
What is the name of the file with the characters to beignored?
ignoreChars.txt
The most frequent character was the letter a with 13occurrences.

Requirements:
The frequency count for the characters must be stored in a Pythondictionary.
The text to be analyzed and the characters to be ignored from thetext must be read
from two separate files.

Expert Answer


Answer to Write a PYTHON program that reads a text file and counts how many occurrences of each character are there in the text. …

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us

× How can I help you?