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
What are some homophones​
ryzh [129]

Answer:

accessary, accessory.

ad, add.

ail, ale.

air, heir.

aisle, I'll, isle.

all, awl.

allowed, aloud.

alms, arms.

5 0
3 years ago
Read 2 more answers
why did my dirtbike just stop when i was riding it, and now when i start it it sounds like it has a knock, and wont stay running
chubhunter [2.5K]

Answer: check the engines i swear if ur talking about an actual bike im gonna be so embarrassed lma0

7 0
3 years ago
Read 2 more answers
The vertical force P acts on the bottom of the plate having a negligible weight. Determine the shortest distance d to the edge o
Greeley [361]

Answer:

The shortest distance d to the edge of the plate is 66.67 mm

Concepts and reason

Moment of a force:

Moment of a force refers to the propensity of the force to cause rotation on the body it acts upon. The magnitude of the moment can be determined from the product of force’s magnitude and the perpendicular distance to the force.

Moment(M) = Force(F)×distance(d)

Moment of inertia ( I )

It is the product of area and the square of the moment arm for a section about a reference. It is also called as second moment of inertia.

First prepare the free body diagram of sectioned plate and apply moment equilibrium condition and also obtain area and moment of inertia of rectangular cross section. Finally, calculate the shortest distance using the formula of compressive stress (σ) in combination of axial and bending stress

Solution and Explanation:

[Find the given attachments]

6 0
4 years ago
Ok there........................................................................
Juliette [100K]

Answer:

ok THERE

Explanation:

4 0
3 years ago
In a particular application involving airflow over a heated surface, the boundary layer temperature distribution may be approxim
diamong [38]

Answer:

Explanation:

In a particular application involving airflow over a heated surface, the boundary layer temperature distribution, T(y), may be approximated as:

[ T(y) - Ts / T∞ - Ts ] = 1 - e^( -Pr (U∞y / v) )

where y is the distance normal to the surface and the Prandtl number, Pr = Cpu/k = 0.7, is a dimensionless fluid property. a.) If T∞ = 380 K, Ts = 320 K, and U∞/v = 3600 m-1, what is the surface heat flux? Is this into or out of the wall? (~-5000 W/m2 , ?). b.) Plot the temperature distribution for y = 0 to y = 0.002 m. Set the axes ranges from 380 to 320 for temperature and from 0 to 0.002 m for y. Be sure to evaluate properties at the film temperature.

3 0
4 years ago
Other questions:
  • Write a MATLAB statement that results in the input request shown in bold. The​ &gt;&gt; shows where your statement is​ typed, an
    7·1 answer
  • Write a function called pyramid(height) that acceptsa parameter ""height"". It then prints a pyramid of that height
    10·1 answer
  • In mechanics of materials, the bending stress of a beam in bending can be determined by the equation σ = MyIwhere expressed in t
    7·1 answer
  • Discurso de Santiago Manuin Valera,
    10·1 answer
  • The ground temperature a few meters below the surface is fairly constant throughout the year and is near the average value of th
    9·1 answer
  • Three capillary tubes with different radius (r1=1.0mm, r2=0.1mm, r3=0.01mm) are inserted into the same cup of water. The surface
    14·1 answer
  • What is the answer to life the universe and everything <br> (worth 95 points!)
    13·2 answers
  • A coil consists of 200 turns of copper wire and have a cross-sectional area of 0.8 mmm square.The mean length per turn is 80 cm
    13·1 answer
  • There are 22 people in the classroom 12 are we
    5·2 answers
  • A car has a steering wheel with a 15 inch diameter that takes 18 lbs of Effort force to move is
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!