I Write a program which does the following: 1) Prompt the user for a file name....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
I Write a program which does the following: 1) Prompt the user for a file name. 2) Read in the file line by line a) Be sure to catch any exceptions that happen, for example if the file doesn't exist. 3) Split each line into words (Hint: Words have spaces before and after them) 4) Split each line into characters a) Count the characters. Note: spaces, periods, commas are not characters. 5) Keep track of the total number of lines, words and characters. 6) Be sure to close out your file correctly. 7) Print out the total number of Lines, Words and Characters. I Write a program which does the following: 1) Prompt the user for a file name. 2) Read in the file line by line a) Be sure to catch any exceptions that happen, for example if the file doesn't exist. 3) Split each line into words (Hint: Words have spaces before and after them) 4) Split each line into characters a) Count the characters. Note: spaces, periods, commas are not characters. 5) Keep track of the total number of lines, words and characters. 6) Be sure to close out your file correctly. 7) Print out the total number of Lines, Words and Characters.
Expert Answer:
Answer rating: 100% (QA)
Here is a simple Introduction The following Python program prompts the user for a file name reads it line by line and calculates the total number of lines words and characters handling exceptions appr... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
installment note, with semiannual interest payments. 1) Calculate the amount of each payment using the PMT function. 2) Prepare the amortization schedule for the loan. Enter a valid Excel formula or...
-
Lab 10: ArrayLists and Files in a GUI Application For this lab, you will work on a simple GUI application. The starting point for your work consists of four files (TextCollage, DrawTextItem,...
-
For this lab, you will work on a simple GUI application. The starting point for your work consists of four files (TextCollage, DrawTextItem, DrawTextPanel, and SimpleFileChooser) in the code...
-
Write a program Tree that takes a command-line argument n and produces the following recursive patterns for n equal to 1, 2, 3, 4, and 8. So b b b h l 4 3 2 1
-
1. Newton, a business owner, signed a ten-year lease beginning in July of 2017, and immediately paid rent for the remainder of 2017, all of 2018, and all of 2019. How much of the rent paid at the...
-
(a) From the curves shown in Figure 10.11 and using Equation 10.18, determine the rate of recrystallization for pure copper at the several temperatures. (b) Make a plot of ln(rate) versus the...
-
Wendy Craven is the sole shareholder of a property management company near the campus of Pensacola Junior College. The business has cash of \($6,000\) and furniture that cost \($12,000\) and has a...
-
The Enron debacle created what one public official reported was a crisis of confidence on the part of the public in the accounting profession. List the parties who you believe were most responsible...
-
Explain what is the difference between mechanical and non-mechanical properties of these materials. State and example for each property of a material. Wood Concrete Brick Glass Steel Asphalt Gypsum...
-
Certain radial tires had useful lives of 35,200, 41,000, 44,700, 38,600, and 41,500 miles. Assuming that these data can be looked upon as a random sample from an exponential population, use the...
-
Question 10 Perform the following calculation and input the answer expressed to the correct number of significant figures. The goal of this question is to see if you understand how the mathematical...
-
Estimate the material cost per case, which is made of a PC-ABS plastic. Assume that 20% of the material is wasted (without recycling), the case is 45 grams, and the current pricing of this PC-ABS...
-
You purchased a boat for $300,000 and agreed to pay the amount over the next 10 years an equal payment at the end of every year. Assuming that the discount rate is 12%, what will be the yearly...
-
For each of the following, give an example of a Markov chain with the desired properties. You may exhibit the chain in any way that makes the example clear (eg. giving the transition matrix, giving...
-
*17-68. The door will close automatically using torsional springs mounted on the hinges. If the torque on each hinge is M = k0, where 0 is measured in radians, determine the required torsional...
-
Use the information provided below to answer the following questions: 1.2.1 Calculate the return on net assets and current ratio for all three companies (expressed to two decimal places). 1.2.2...
-
The given table contains the value of a house and the amount of rental income in a year that the house brings in. Create a scatter plot and find a regression equation between house value and rental...
-
What types of inventory issues Starbucks might reflect upon at the end of each year? The mission of Starbucks is to inspire and nurture the human spiritone person, one cup, and one neighborhood at a...
-
Ray and Maria Gomez have been married 3 years. They live at 1610 Quince Ave., McAllen, TX 78701. Ray works for Palm Oil Corporation and Maria works for the City of McAllen. Maria's Social Security...
-
Mallory Corporation has a calendar year-end. The corporation has paid estimated payments of $10,000 during 2012 but still owes an additional $5,000 for its 2012 tax year. a. When is the 2012 tax...
-
Yolanda earns $112,000 in 2012. Calculate the FICA tax that must be paid by: Yolanda:.....................Soc.Sec..................$__________...
-
To determine an optimum sample size when sampling methods are used in a substantive test, all of the following factors must be considered except the a. Variation in the population. b. Risk levels the...
-
Which of the following sample planning factors would influence the sample size for a substantive test of details for a specific account? Expected amount of misstatements No Measure of tolerable...
-
The relationship between the sampling risk of incorrect acceptance and the sample size of substantive tests is a. Inverse. b. Positive. c. Indeterminate. d. None of the above.
Study smarter with the SolutionInn App