Question: 1. Programming Exercise #6 (Average Number of Words): The user will enter the name of the text file to be read. a. Name your Python
1. Programming Exercise #6 (Average Number of Words): The user will enter the name of the text file to be read. a. Name your Python program AverageWordCount.py b. There are two text files provided with this lab assignment, text.txt and jabberwocky.txt. Copy these two files into the same folder where you create your Python program. c. Your program should have a main function that asks the user for the name of the file to be opened, opens the text file, reads the contents into a list, closes the file, then reads each line to count lines and words. d. Hint: Use counters for the number of lines and the number of words. Each time you start a new line, increment both the line counter and the word counter by 1. Each time you encounter a space, increment the word counter again by 1. e. Display the number of lines read, the number of words read, and the average number of words per line. Format the average words per line figure to display with 1 decimal place.
text file - 1 textfilename-jabberworcky.txt
Mary had a little lamb. Today is Saturday and I am working at the school to get the course ready because it is due on Monday. I am listening to the radio and am enjoying it. This is a test to see if the program runs correctly will different files. Smile for it is a good day. Do your homework
text file 2 textfile name text.txt
No one is unaware of the name of that famous English shipowner, Cunard. In 1840 this shrewd industrialist founded a postal service between Liverpool and Halifax, featuring three wooden ships with 400-horsepower paddle wheels and a burden of 1,162 metric tons. Eight years later, the company's assets were increased by four 650-horsepower ships at 1,820 metric tons, and in two more years, by two other vessels of still greater power and tonnage. In 1853 the Cunard Co., whose mail-carrying charter had just been renewed, successively added to its assets the Arabia, the Persia, the China, the Scotia, the Java, and the Russia, all ships of top speed and, after the Great Eastern, the biggest ever to plow the seas. So in 1867 this company owned twelve ships, eight with paddle wheels and four with propellers. If I give these highly condensed details, it is so everyone can fully understand the importance of this maritime transportation company, known the world over for its shrewd management. No transoceanic navigational undertaking has been conducted with more ability, no business dealings have been crowned with greater success. In twenty-six years Cunard ships have made 2,000 Atlantic crossings without so much as a voyage canceled, a delay recorded, a man, a craft, or even a letter lost. Accordingly, despite strong competition from France, passengers still choose the Cunard line in preference to all others, as can be seen in a recent survey of official documents. Given this, no one will be astonished at the uproar provoked by this accident involving one of its finest steamers.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
