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]
4 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]4 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
List all the qualities of an engineer?
Dennis_Churaev [7]

Answer:

Math and Computer Skills. A qualified engineer should be good at math, at least through the level of calculus and trigonometry, and understand the importance of following the data when making design decisions.

Organization and Attention to Detail.  

Curiosity.  

Creativity.  

Critical Thinking.

Intuition.

Explanation:

6 0
2 years ago
The mathematical model for finite element method in structural mechanics is the
zysi [14]

Explanation:

Conservation of velocity equation

3 0
3 years ago
Read 2 more answers
A seamless pipe 800mm diameter contains a fluid under a pressure of 2N/mm2. If the permissible tensile stress is 100N/mm2, find
Bad White [126]

Answer:

8 mm

Explanation:

Given:

Diameter, D = 800 mm

Pressure, P = 2 N/mm²

Permissible tensile stress, σ = 100 N/mm²

Now,

for the pipes, we have the relation as:

\sigma=\frac{\textup{PD}}{\textup{2t}}

where, t is the thickness

on substituting the respective values, we get

100=\frac{\textup{2\times800}}{\textup{2t}}

or

t = 8 mm

Hence, the minimum thickness of pipe is 8 mm

3 0
3 years ago
Water from the Earth's surface turns into a gas, or water vapor, when it is warmed and
bagirrra123 [75]

Answer:

Evaporation.

Explanation:

Evaporation is the stage of the Water Cycle where water turns into water vapor. The steps following Evaporation in order include Condensation, Precipitation, and Transpiration.

4 0
3 years ago
Read 2 more answers
You are investigating surface hardening in iron using nitrogen gas. Two 5 mm thick slabs of iron are separately exposed to nitro
Luden [163]

Answer and Explanation:

The explanation is attached below

4 0
3 years ago
Other questions:
  • Two points along a wire are labeled Xand Y. The current is measured to be iXY= –3A.The reference direction of iXY is defined by
    11·1 answer
  • When trying to solve a frame problem it will typically be necessary to draw many free body diagrams. a)-True b)-False
    6·1 answer
  • A piston-cylinder apparatus has a piston of mass 2kg and diameterof
    12·1 answer
  • Air initially at 120 psia and 500o F is expanded by an adiabatic turbine to 15 psia and 200o F. Assuming air can be treated as a
    10·1 answer
  • Which of the following is part of the highway
    11·2 answers
  • Determine the number of flipflops required to build a binary counter that count from 0 to 2043
    14·1 answer
  • The reversible and adiabatic process of a substance in a compressor begins with enthalpy equal to 1,350 kJ/kg, and ends with ent
    15·1 answer
  • List six clues that indicates that you are approaching an intersection
    10·1 answer
  • A particular electromagnetic wave travelling in vacuum is detected to have a frequency of 3 × 10 12 Hz. How much time will it ta
    6·1 answer
  • Can someone help me LA project pls :((
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!