Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USE PYTHON (f) Suppose you have a list of strings containing English text, like this: [ Four score and seven years ago, our fathers brought

USE PYTHON

(f) Suppose you have a list of strings containing English text, like this:

[ "Four score and seven years ago, our fathers brought forth on", "this continent a new nation, conceived in liberty and dedicated", "to the proposition that all men are created equal. Now we are", " engaged in a great civil war, testing whether that nation, or any", "nation so conceived and so dedicated, can long endure. " ] 

There might be additional spacing or punctuation, as shown in the last two lines above.

(f.1) Write the function print_line_numbers that takes a list of strings and prints each string preceded by a line number:

1: Four score and seven years ago, our fathers brought forth on 2: this continent a new nation, conceived in liberty and dedicated 3: to the proposition that all men are created equal. Now we are 4: engaged in a great civil war, testing whether that nation, or any 5: nation so conceived and so dedicated, can long endure. 

If there are 10 lines or more, the text won't line up nicely. Use the format method to print each line number in a five-character-wide field. (A nifty enhancement would be to make the line number field width exactly as long as it has to be to display the longest line number.)

(f.2) Write the function stats that takes a list of strings and prints statistics as follows:

 16824 lines in the list 483 empty lines 53.7 average characters per line 65.9 average characters per non-empty line 

Follow the formatting shown.

(f.3) Write the function list_of_words that takes a list of strings as above and returns a list of individual words with all white space and punctuation removed (except for apostrophes/single quotes).

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

Advances In Spatial And Temporal Databases 11th International Symposium Sstd 2009 Aalborg Denmark July 8 10 2009 Proceedings Lncs 5644

Authors: Nikos Mamoulis ,Thomas Seidl ,Kristian Torp ,Ira Assent

2009th Edition

3642029817, 978-3642029813

More Books

Students also viewed these Databases questions

Question

What is a jumbo mortgage?

Answered: 1 week ago

Question

Identify the different anxiety disorders.

Answered: 1 week ago