Question: Write Python Code that does the following: Uploads a text file containing this Lipsum into Google Colab. Add exception handling to this process so that

Write Python Code that does the following:

Uploads a text file containing this Lipsum into Google Colab.

Add exception handling to this process so that if the file upload is aborted, or if the file cannot be read, that a graceful error message along the lines of "Sorry, the file cannot be processed." is displayed instead of a nasty Python exception message.

Raise an exception and abort processing if the file uploaded does not have .txt as its extension.

Counts the number of each word, excluding punctuation and disregarding case, and then displays each single word on a line with the number of instances of that word as follows: Interface - 23 system - 41 broadband - 12

Calculate the average length of all the words used in this lipsum, excluding punctuation, both as an integer and as a floating-point number.

Calculate the total word count of this lipsum.

HINT - You can get the lowercase rendering of a string in Python by using the .lower() method with a variable containing a string, e.g. myVariable.lower()

HINT - You can use the string .replace(...) method to replace text in a string:

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!