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...
-
"I work for a financial services firm. We do new product development all the time, and a lot of it is of the incremental variety. You know, bundle credit card access to a savings account, bundle the...
-
Explain why all mutations are not necessarily harmful?
-
Brugha Research Associates (BRA) just completed a controlled store test of a proposed new packaging for the Aussie brand of cookies. BRA collected eight weeks of pretest period sales data for Aussie...
-
A mining corporation purchased $120,000 of production machinery and depreciated it using SOYD depreciation , a 5-year depreciable life, and zero salvage value . The corporation is a profitable one...
-
The last dividend paid by Klein, Inc. was $2.20. Klein's growth rate is expected to be 10 percent for two years, after which dividends are expected to grow at a rate of 6 percent forever. The...
-
Values for the NASDAQ composite index during the 1,500 days preceding March 10, 2006, can be downloaded from the authors web site. Calculate the one-day 99% VaR and the one-day 99% ES on March 10,...
-
Flag question The symbol used for representing Independent sources a. Circle Ob. Triangle O c. Square Od. Diamond
-
Three main modules included in the Apache NetBeans IDE are . a. JEUS 7 application server, JBoss Application Server 6, Caucho Resin 4.0 b. Java EE, Java SE, Maven c. NetBeans Profiler, GUI design...
-
Working in small groups, plan a presentation to different audiences. Imagine that youre the management team of a moving company and are announcing the acquisition of a storage company. The storage...
-
The NetBeans IDE is an open-source integrated development environment, and it only supports development of all Java application types. (True/False)
-
Watch two TED Talks. Identify storieseither parts of a presentation or the entire presentation as a story. How does each story follow the format shown in Figure 3? In what ways does it differ? How...
-
An Apache NetBeans module is a group of Java classes that provides an application with a specific feature. (True/False)
-
How deadlock can be prevented? OR Explain deadlock prevention.
-
The following cost information was provided to you for analysis: September 12,000 Units Produced Costs: TIC TAC TOE TING August 10,000 P80,000 70.000 60.000 50,000 How much is the fixed cost per...
-
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,...
-
Power feed is not provided on the following drilling machine : (a) bench drill press (b) gang drilling machine (c) radial drilling machine (d) all of the above.
-
The lathe post not provided with power feed is (a) lead screw (b) carriage (c) compound rest (d) cross slide
-
External taper can be obtained by (a) taper attachment (b) form tool (c) compound rest (d) tail stock offset.
Study smarter with the SolutionInn App