Answered You can hire a professional tutor to get the answer.

QUESTION

Character Counter IN PYTHON PLEASE PUT COMMENTS SO I KNOW WHAT EVERY LINE IS DOING. Your program should use a command line argument to give the name...

Character Counter IN PYTHON PLEASE PUT COMMENTS SO I KNOW WHAT EVERY LINE IS DOING.

Your program should use a command line argument to give the name of the document that will be analyzed.

To analyze a document, read in the text and count how many times each letter, number or symbol occurs in the text. Upper and lower-case letters should be considered the same for the counting process (you can convert all letters to lower case).

You should then compute the percentage that each letter, number and symbol that occurred in the document is of the total . Print this data in a frequency table. Use an appropriate collection to store the information.

Print the table to the console and into a file called output.txt.

Make the output as follows using the ' '.format() we discussed in class:

1. Centered at the top line of the file/console, print the title of the report as "Frequency of ASCII Characters in the Text by <Your Name>", followed by two newlines. #This will be marked wrong by repl.it, but I will give you credit if you use your name, not mine. If you use my name, I will mark it wrong event tho repl.it will mark it right.

2. On the next line show the name of the input file, as:

"Input File: myInput.txt", followed by a newline.

3. On the next line print the following titles centered above each column of data: "Char", "Number", "Percent" followed by a newline.

4. For each character, print the following information:

Centered in 4 spaces, show the character (Note: Since upper and lower case letters are combined, show the lower case letter, e.g. for a and A, show a), then a tab

Right justified in 10 spaces show the whole number value for the number of occurrences of the character in your file, then a tab

Right justified in 9 spaces, with 5 decimal places, show the percentage of the whole for this character, followed by the percent sign (%), and a newline at the end. # note that an extra character is needed in this column for the % symbol, align your title properly.

5. When you are done printing the character data:

print '=' for the entire data column width for the Number and Percentage columns.

Print the total for Number column in 10 spaces alignd with the column above it.

Print the total percent for all characters (should be 100% or very close to it, there can be rounding error), in the same format as the column above it with two newlines at the end.

At the end of the output/file, print a closing message, "Thank you for using Character Counter, bye!"

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question