Question: Make a .py file called Fx_4. Then, perform the following exercise : Write python code that accepts string inputs formatted such as the following: str

Make a .py file called Fx_4. Then, perform the following exercise:

Write python code that accepts string inputs formatted such as the following:

str = X-DSPAM-Confidence:0.8475

Use find and string slicing to extract the portion of the string after the colon character and then use the float function to convert the extracted string into a floating point number. Keep a sum of all the confidence values extracted.

Put this code in a loop than runs until the user enters quit or QUIT. When the user quits, print out the average X-DSPAM-Confidence. Bad input (input that isnt quit OR doesnt have a confidence as above) should be rejected appropriately.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!