Write a program that 1 Prompts for a filename 2. Then opens that file and reads...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program that 1 Prompts for a filename 2. Then opens that file and reads through it, looking for lines like X-DSPAM-Confidence 3. Extract the floating-point values from the end of each of the lines 4. Sum the total 5. Count how many lines 6. Compute the average of those values and produce output like: Count: 27 Mean 15: 0.7507185185185187 Hints: Do not use the sum() function or a variable named sum in your solution. You'll need to loop through the file Use a string method (like "startswith" to help parse the file) see the Py3 Docs String splicing to get the value out. See how long the X-DSPAM-Confidence: 0.8475 string is and extract the number . After splicing out the value be sure to make the value a float You'll need to create variables to hold the count and totals to be used at the end to computer the (mean average Write a program that 1 Prompts for a filename 2. Then opens that file and reads through it, looking for lines like X-DSPAM-Confidence 3. Extract the floating-point values from the end of each of the lines 4. Sum the total 5. Count how many lines 6. Compute the average of those values and produce output like: Count: 27 Mean 15: 0.7507185185185187 Hints: Do not use the sum() function or a variable named sum in your solution. You'll need to loop through the file Use a string method (like "startswith" to help parse the file) see the Py3 Docs String splicing to get the value out. See how long the X-DSPAM-Confidence: 0.8475 string is and extract the number . After splicing out the value be sure to make the value a float You'll need to create variables to hold the count and totals to be used at the end to computer the (mean average
Expert Answer:
Answer rating: 100% (QA)
Solution Here is the Python code to calculate the average spam confidence from a file Python def ave... 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
-
Problem 4. (a) Determine the equivalent stiffness for the figure below as a single spring system. k. F k k3 Figure. Multiple springs in series and parallel (b) Analyze forces/moments on the systems...
-
Truman, an HR Manager, was recently hired at Fang corp. to help make the organization a more attractive place to work. Whereas their competitors have the resources to offer expensive benefits and...
-
Explain how family decision making may differ from the individual decision making process. What types of conflicts have you seen during the family decision making process, and what strategies have...
-
Discuss how efficiency and effectiveness are used to aid in decision making within a healthcareorganization. Is one more important than the other? Describe the importance of financial information in...
-
You intend to use an electron microscope to study the structure of some crystals. For accurate resolution, you want the electron wavelength to be 1.00 nm. (a) Are these electrons relativistic? How do...
-
Which of the following is the expected count of females who respond Almost certain? a. 487.7 b. 525 c. 965 d. 1038.8 e. 1174 The National Longitudinal Study of Adolescent Health interviewed a random...
-
Use the all-possible-regressions selection on the methanol oxidation data in Table B.20. Perform a thorough analysis of the best candidate models. Compare your results with stepwise regression....
-
The comparative balance sheet of Canace Products Inc. for December 31, 2016 and 2015, is as follows: The income statement for the year ended December 31, 2016, is as follows: Additional data obtained...
-
Evaluate the impact of capital structure decisions, including debt-equity ratio optimization, on firm value and cost of capital .
-
In the Chapter 11 Data Analytics Case, you used Tableau to examine a data set and create calculations to compare the relative age of two companies assets. In this case you continue in your role as an...
-
The global irradiance was measured in Lisbon, latitude 38,5N, with a pyranometer to be 532 W/m 2 and the diffuse irradiance was measured with a pyranometer with a shading ring to be 220 W/m 2 . The...
-
George Oldman, a Toronto antiquerug dealer, advertises in the January issue of the Rug Dealer's Rag magazine: For sale: 150yearold Sultanabad Persian. 2.5 m x 4 m. Exceptional quality. Phone (416)...
-
What is meant by an anti-lapse clause, and how do these usually work? Do you believe that all states and all types of policies should have anti-lapse clauses, and why or why not?
-
The United States is the only major nation in the world that generally utilizes an at-will employment system generally. Only the state of Montana requires that cause be shown in a dismissal. Which...
-
Describe the type of internship that fits your skills, interests, and experiences well. Be as specific as possible.
-
What are examples of cybercrime to someone outside the field of criminal justice? What is an example of cybercrime? What is the domestic and international impact of cybercrime? What law enforcement...
-
Consider each of the electric- and magnetic-field orientations. What is the direction of propagation of the wave if E*-Ei^,B=Bj^E=Ei^, B-=-Bj^. Express the direction of the propagation vector,...
-
Diamond Walker sells homemade knit scarves for $25 each at local craft shows. Her contribution margin ratio is 60%. Currently, the craft show entrance fees cost Diamond $1,500 per year. The craft...
-
Mary paid $2,000 of state income taxes in 2012. The total sales tax she paid during 2012 was $5,500, which included $3,000 for the cost of a new car. How should Mary treat the taxes paid on her 2012...
-
Carl Conch and Mary Duval are married and file a joint return. They live at 1234 Mallory Sq. Apt. 64, Key West, FL 33040. Carl works for the Key Lime Pie Company and Mary is a homemaker after losing...
-
Sophie is a single taxpayer. For the first payroll period in October 2012, she is paid wages of $3,250 monthly. Sophie claims three allowances on her Form W-4. a. Use the percentage method to...
-
You have been asked to consult for an entrepreneur who is assembling investors for a new professional sport league. A critical decision for the league will be whether to organize under a...
-
Does a company share its risk by issuing equity or debt?
-
How are the features of a convertible bond similar to both debt and equity?
Study smarter with the SolutionInn App