Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python language Function Name: error_finder Parameters: numList ( list ), indexList ( list) Returns: (average, errorDict) ( tuple ) Description: Write a function that takes

python language

image text in transcribed

Function Name: error_finder Parameters: numList ( list ), indexList ( list) Returns: (average, errorDict) ( tuple ) Description: Write a function that takes in a list of numbers and a list of indices. Note that in- dexList may not only contain valid indices. The function should keep track of the number and type of errors that occur. Specifically, it should account for IndexError and TypeError. It should return the average of all the numbers at valid indices and a dictionary containing the number and type of errors together in a tuple. errorDict should be formatted as follows: {"IndexError": 0, "TypeError": 0} If none of the indices in the indexList are valid, the function should return 0 as the average. >>> numList = [4,5,1,7,2,3,6] >>> indexList = [0, "4", (1,), 18, "", 3, 5.0, 7.0, {}, 20] >>> print(error_finder(numList, indexList)) (5.5, {'IndexError': 2, "TypeError': 6}) >>> numList = [1, 0, 18, 22, 3, -1, 5, 4, 9] >>> indexList = [(7,), 4.0, {True: False}, 0, [11], "not an index", 12, 2.5] >>> print(error_finder(numList, indexList)) (1.0, {'IndexError': 1, 'TypeError': 6})

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 15th International Conference Dexa 2004 Zaragoza Spain August 30 September 3 2004 Proceedings Lncs 3180

Authors: Fernando Galindo ,Makoto Takizawa ,Roland Traunmuller

2004th Edition

3540229361, 978-3540229360

More Books

Students also viewed these Databases questions

Question

Explain the nature of human resource management.

Answered: 1 week ago

Question

Write a note on Quality circles.

Answered: 1 week ago

Question

Describe how to measure the quality of work life.

Answered: 1 week ago