Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions