Question: 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.

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
Step by Step Solution
3.32 Rating (155 Votes )
There are 3 Steps involved in it
Solution Here is the Python code to calculate the average spam confidence from a file Python def ave... View full answer
Get step-by-step solutions from verified subject matter experts
