1. Write a program called q1.py that analyzes and prints file statistics. First, prompt the user...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Write a program called q1.py that analyzes and prints file statistics. First, prompt the user for the name of a file. Then, read and analyze the file and display the following statistics: total number of characters, number of sentences, and number of words. Here are some notes regarding the above statistics you will collect. A character is any symbol in the text file, Examples of characters include letters, numerical digits, punctuation marks, and "invisible characters such as whitespace and newline characters. • Assume a word is separated by whitespace and/or newline characters. • Assume sentences end in either a period, question mark, or exclamation point. Programming tips. You'll need to take advantage of the strip() and split() func- tions for strings. Please see the Topic 3 lecture notes (along with in-class programs) for examples of reading files and stripping and splitting strings. Example #1. The user enters the filename five-letter-words.txt (line 1). The output of the program is then displayed (lines 3-5). Enter a filename: five-letter-words.txt Characters: 16500 4 Sentences: 0 Words: 2750 1 Example #2. The user enters the filename gettysburg.txt (line 1). The output of the program is then displayed (lines 3-5). Enter a filename: gettysburg.txt 3 Characters: 1447 4 Sentences: 10 Words: 267 1. Write a program called q1.py that analyzes and prints file statistics. First, prompt the user for the name of a file. Then, read and analyze the file and display the following statistics: total number of characters, number of sentences, and number of words. Here are some notes regarding the above statistics you will collect. A character is any symbol in the text file, Examples of characters include letters, numerical digits, punctuation marks, and "invisible characters such as whitespace and newline characters. • Assume a word is separated by whitespace and/or newline characters. • Assume sentences end in either a period, question mark, or exclamation point. Programming tips. You'll need to take advantage of the strip() and split() func- tions for strings. Please see the Topic 3 lecture notes (along with in-class programs) for examples of reading files and stripping and splitting strings. Example #1. The user enters the filename five-letter-words.txt (line 1). The output of the program is then displayed (lines 3-5). Enter a filename: five-letter-words.txt Characters: 16500 4 Sentences: 0 Words: 2750 1 Example #2. The user enters the filename gettysburg.txt (line 1). The output of the program is then displayed (lines 3-5). Enter a filename: gettysburg.txt 3 Characters: 1447 4 Sentences: 10 Words: 267
Expert Answer:
Answer rating: 100% (QA)
Heres a Python program called q1py that analyzes and prints file statistics as described ... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
Lamonda Corporation uses a job order cost system. On April 1, the accounts had balances as shown in the T- accounts below: The following transactions occurred during April: a. Purchased materials on...
-
In this assignment, you are writing a program that converts common texting abbreviations to English words to allow people like yours truly can understand. For the assignment, you are provided with a...
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
A ball, which we can treat as a point charge, has a charge of +Q. This ball is 50 cm away from a ball of charge-100, which is fixed in position. The +Q ball is 30 cm vertically below, and 40 cm...
-
What are the units of measurement for tangential speed? For rotational speed?
-
Tristen Company purchased a five-story office building on January 1, 2016, at a cost of $5,000,000. The building has a residual value of $200,000 and a 30-year life. The straight-line depreciation...
-
In leaching, the final saturated raffinate often contains a significant amount of solvent. For example, this occurs in Example 14-2. How do you recover this solvent? Example 14-2 We wish to treat...
-
Representatives of the Patriot Insurance Company take medical information over the telephone from prospective policy applicants prior to a visit to the applicants place of residence by a registered...
-
Problem 10-13 (Algo) Basic Variance Analysis; the Impact of Variances on Unit Costs [LO10-1, LO10-2, LO10-3] Koontz Company manufactures a number of products. The standards relating to one of these...
-
Traditionally firms raise capital in the primary market issuing either fixed or floating rate debt. Both bond structures expose the firm to interest rate risk. The financial derivatives market...
-
After the 30 years of working Charlie Conway has saved $950,000 in a 401k account for his retirement. If Charlie decides to take annual distributions to empty the account during the next 20 years,...
-
The follwoing is the summary of the entries in a Contract ledger as on the 3 1 st December 2 0 1 0 in respect of Contract No . 5 1 : Materials bought directly Rs . 3 5 , 0 0 0 Materials from stores...
-
The Windows Virtual Desktop provides a way to access your computer-based resources on multiple computers without having to have them stored on the computer you are sitting at. Explain why this method...
-
1 . Taub Company manufactures backpack blowers. The firm had the following inventories. Jan 1 , 2 0 2 4 Dec 3 1 , 2 0 2 4 Finished goods $ 1 4 2 , 0 0 0 $ 9 2 , 0 0 0 Work in process $ 2 6 2 , 0 0 0...
-
A situation analysis is a detailed description of a brand's current marketing situation. A SWOT analysis draws upon facts contained in the situation analysis to determine the strengths, weaknesses,...
-
What are the two main approaches for networking? Distinguish between the fundamental features of these approaches? Which networking approach is mainly used for the Internet? Why? What are access...
-
Caspian Sea Drinks' is financed with 69.00% equity and the remainder in debt. They have 11.00-year, semi-annual pay, 5.52% coupon bonds which sell for 97.01% of par. Their stock currently has a...
-
Why do CPA firms sometimes use a combination of positive and negative confirmations on the same audit?
-
Write a program that will find a path in a maze, as shown in Figure 18.13a. The maze is represented by an 8 * 8 board. The path must meetthe following conditions:? The path is between the upper-left...
-
Following the example of the Circle class in Section 9.2, design a class named Stock that contains: A string data field named symbol for the stocks symbol. A string data field named name for the...
-
Write a program that reads an unspecified number of integers and finds the one that has the most occurrences. The input ends when the input is 0. For example, if you entered 2 3 40 3 5 4 3 3 3 2 0,...
-
Refer to the data given for the Sky Company in Problem P12-4A. Required a. Calculate the change in cash that occurred in 2019. b. Prepare a statement of cash flows using the direct method. Use one...
-
The Lowe Company's income statement and comparative balance sheets as of December 31 of 2019 and 2018 are presented below: During the year, Lowe Company sold equipment for \(\$ 27,000\) cash that...
-
The Madison Company's income statement and comparative balance sheets as of December 31 of 2019 and 2018 follow: During 2019, \(\$ 27,000\) of cash dividends were declared and paid. A patent valued...
Study smarter with the SolutionInn App