1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
jarptica [38.1K]
3 years ago
8

Description: Write a function that takes in a list of numbers and a list of indices. Note that indexList may not only contain va

lid 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 follow
Engineering
1 answer:
MAVERICK [17]3 years ago
7 0

Answer:

Python code is explained below

Explanation:

average , count, indexerror, typeerror variables are initialised to 0

Then, for loop is used to traverse the indexlist, if type is not right, typeerror is incremented, else if index is not right, indexerror is incremented, otherwise, count is incremented, and the number is added to average.

At last, average variable which contains the sum of numbers is divided by count to get average.

Here is the code:

def error_finder(numList, indexList):

average = 0

count = 0

indexerror = 0

typeerror = 0

 

for i in range(len(indexList)):

if type(indexList[i])==int:

if indexList[i]>=len(numList) or i<0:

indexerror = indexerror + 1

else:

average = average + numList[indexList[i]]

count = count+1

else:

typeerror = typeerror + 1

 

d = {"IndexError": indexerror, "TypeError":typeerror}

 

average = average/count

 

return(average, d)

print(error_finder([4, 5, 1, 7, 2, 3, 6], [0, "4", (1, ), 18, "", 3, 5.0, 7.0, {}, 20]))

You might be interested in
What the phat is this
Alex17521 [72]

Answer:

It's Brainly ;)

8 0
3 years ago
Read 2 more answers
A vertical cylinder (Fig. P3.227) has a 61.18-kg piston locked with a pin, trapping 10 L of R-410a at 10◦C with 90% quality insi
Whitepunk [10]

Hey! How are you? My name is Maria, 19 years old. Yesterday broke up with a guy, looking for casual sex.

Write me here and I will give you my phone number - *pofsex.com*

My nickname - Lovely

4 0
2 years ago
Compute L, T, M, LC, and R and stations of the BC and EC for the circular curve with the given data of: I (delta) = 22°15′00" an
Mars2501 [29]

Answer:

L = 475.718

T = 240.89 ft

M = 23.0195

LC = 472.728

R = 1225 ft

Explanation:

See the attached file for the calculation.

8 0
3 years ago
A right triangle has a base of 12 inches and a height of 30 inches, what is the centroid of the triangle?​
aliina [53]

Answer:

the correct answer is 42

4 0
2 years ago
5. Name two health problems that fume can cause?<br> a)....<br> b)......
Vlad [161]

Answer:

A) Cancer of the Lungs

B)Larynx and Urinary Tract, as well as nervous system and kidney damage

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • Determine the Thevenin/Norton Equivalent Circuit with respect to the terminalsa,bas shown in the figure. (Here 1A is an independ
    11·1 answer
  • Consider a two-dimensional incompressible velocity potential phi = ???????? cos theta + ????????theta, where B and L are constan
    8·1 answer
  • Consider a process in which a carbon-based fuel is combusted in the presence of 70% excess oxygen (assume that all of the oxygen
    10·1 answer
  • On a hot summer day, a student turns his fan on when he leaves his room in the morning. When he returns in the evening, will the
    5·1 answer
  • In a four bar mechanism, L, is a fixed link; L2 is driver crank; L3 is coupler and L4 is follower crank. L=27 cm, L3 =5 cm and L
    5·1 answer
  • Need answers for these please ​
    15·1 answer
  • A thermistor is a temperature‐sensing element composed of a semiconductor material, which exhibits a large change in resistance
    13·1 answer
  • The shaft is hollow from A to B and solid from B to C. The shaft has an outer diameter of 79 mm, and the thickness of the wall o
    6·1 answer
  • A long rod of 60-mm diameter and thermophysical properties rho=8000 kg/m^3, c=500J/kgK, and k=50 W/mK is initally at a uniform t
    8·1 answer
  • which of the following processes would be appropriate for cutting a narrow slot, less than 0.015 inch wide, in a 3/8- inch thick
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!