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
g A steel water pipe has an inner diameter of 12 in. and a wall thickness of 0.25 in. Determine the longitudinal and hoop stress
zvonat [6]

Answer:

a) \mathbf{\sigma _ 1 = 4800 psi}

     \mathbf{ \sigma _2 = 0}

b)\mathbf{\sigma _ 1 = 6000 psi}

  \mathbf{ \sigma _2 = 3000 psi}

Explanation:

Given that:

diameter d = 12 in

thickness t = 0.25 in

the radius = d/2 = 12 / 2 = 6 in

r/t = 6/0.25 = 24

24 > 10

Using the  thin wall cylinder formula;

The valve A is opened and the flowing water has a pressure P of 200 psi.

So;

\sigma_{hoop} = \sigma _ 1 = \frac{Pd}{2t}

\sigma_{long} = \sigma _2 = 0

\sigma _ 1 = \frac{Pd}{2t} \\ \\ \sigma _ 1 = \frac{200(12)}{2(0.25)}

\mathbf{\sigma _ 1 = 4800 psi}

b)The valve A is closed and the water pressure P is 250 psi.

where P = 250 psi

\sigma_{hoop} = \sigma _ 1 = \frac{Pd}{2t}

\sigma_{long} = \sigma _2 = \frac{Pd}{4t}

\sigma _ 1 = \frac{Pd}{2t} \\ \\ \sigma _ 1 = \frac{250*(12)}{2(0.25)}

\mathbf{\sigma _ 1 = 6000 psi}

\sigma _2 = \frac{Pd}{4t} \\ \\  \sigma _2 = \frac{250(12)}{4(0.25)}

\mathbf{ \sigma _2 = 3000 psi}

The free flow body diagram showing the state of stress on a volume element located on the wall at point B is attached in the diagram below

8 0
3 years ago
Which of the following factors does not promote safety in the shop?
sergey [27]
“Thinking about pleasant things to pass the time” would not promote safety in the shop because it would be taking the focus away from important tasks, which in turn decreases safety.
6 0
3 years ago
At 45° latitude, the gravitational acceleration as a function of elevation z above sea level is given by g = a − bz , where a =
Ahat [919]

Answer:

8861.75 m approximately 8862 m

Explanation:

We need to remember Newton's 2nd Law which says that the force experienced by an object is proportional to his acceleration and that the constant of proportionality between those two vectors correspond to the mass of the object.

F=ma for the weight of an object (which is a force) we have that the acceleration experienced by that object is equal to the gravitational acceleration, obtaining that  W = mg

For simplicity we work with g =9.807 \frac{m}{s^{2}} despiting the effect of the height above sea level. In this problem, we've been asked by the height above sea level that makes the weight of an object 0.30% more lighter.

In accord with the formula g = a-bz the "normal" or "standard" weight of an object is given by W = mg = ma when z = 0, so we need to find the value of z that makes W = m(a-bz) = 0.997ma meaning that the original weight decrease by a 0.30%, so now we operate...

m(a-bz) = 0.997ma now we group like terms on the same sides ma(1-0.997) = mbz we cancel equal tems on both sides and obtain that z = \frac{a}{b} (0.003) = \frac{9.807 \frac{m}{s^{2} } }{3.32*10^{-6} s^{-2} } (0.003) = 8861.75 m

7 0
3 years ago
When mining diamonds with a stone pick what will be the outcome
Soloha48 [4]

Answer:

The diamond ore will break and you won't get any diamonds.

Explanation:

4 0
3 years ago
Read 2 more answers
How should you mark a component listed on the VCU form that
Anna [14]
I’m not that shareholding about it but I think the answer is C mark it green I hope I don’t get it rong
7 0
2 years ago
Other questions:
  • computer language C++ (Connect 4 game)( this is all the info that was givin no input or solution) I used the most recent version
    6·1 answer
  • The themes around which social sciences texts are organized boost understanding by
    11·1 answer
  • 14. A large car fire presents the possibility of
    10·2 answers
  • A heat recovery system​ (HRS) is used to conserve heat from the surroundings and supply it to the Mars Rover. The HRS fluid loop
    12·1 answer
  • a digital multimeter is set to read dc volts on the 4 volt scale the meter leads are connected to a 12 volt battery what will th
    14·2 answers
  • Users say that the game is interesting to look at but the music gets annoying
    9·1 answer
  • In water and wastewater treatment processes a filtration device may be used to remove water from the sludge formed by a precipit
    10·1 answer
  • A motor driven water pump operates with an inlet pressure of 96 kPa (absolute) and mass flow rate of 120 kg/min. The motor consu
    7·1 answer
  • After a strong storm, a worker does not realize that a power transmission line has fallen on his car and is electrocuted while o
    9·1 answer
  • 25 In differential aeration corrosion, rich oxygenated parts are
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!