Question: Please help me with this homework problem, using python 2.X Given the following python statement avg_str = 'Average value read: 0.72903' Use the find() method

Please help me with this homework problem, using python 2.X

Given the following python statement

avg_str = 'Average value read: 0.72903'

Use the find() method 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 value. Your code should provide a general solution, meaning that the number you extract could be any floating point number (it may or may not be preceded by a space, it may or may not begin with 0, it may or may not end with 3, and its length is not known before your program executes). A generalized solution will successfully extract values such as 0.72903, 3.14159265359, 2.81, etc.. In other words, your solution will not make any a priori assumptions regarding the format or content of the number, other than it being a floating point value that follows the colon character. Save your code in a file named parse_float.py.

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!