Question: Python Complete the calculate_average () function that takes a single parameter, string_list, a list of strings. The function should process each string in string_list and

Python Complete the calculate_average () function that takes a single parameter, string_list,Python

Complete the calculate_average () function that takes a single parameter, string_list, a list of strings. The function should process each string in string_list and calculate the average value of the string representations of numbers in the list. Strings that do not represent numbers should be ignored. The function returns the average. Things to note: String representations of floating-point values should be rounded to the nearest integer value using the round() function, when calculating the average. The calculated average should be rounded to the nearest integer value using the round() function. If there are no string representations of numbers in string_list or string_list is empty, then the function should return O. You MUST use the try... except syntax in your solution. Some examples of the function being used are shown below. For example: Test Result print("Average:", calculate_average(["1.5", "hello", "world", "TRUE", "2", "3", "5.5"])) Average: 3 print("Average:", calculate_average(["a", "quick", "brown", "fox", ""])) Average: 0

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!