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
Select the best answer for the question.
dalvyx [7]
I think the Acid level
5 0
3 years ago
Why do we care about a material's ability to resist torsional deformation?
lesya692 [45]

Answer:

(A) Because the angle of twist of a material is often used to predict its shear toughness

Explanation:

In engineering, torsion is the solicitation that occurs when a moment is applied on the longitudinal axis of a construction element or mechanical prism, such as axes or, in general, elements where one dimension predominates over the other two, although it is possible to find it in diverse situations.

The torsion is characterized geometrically because any curve parallel to the axis of the piece is no longer contained in the plane initially formed by the two curves. Instead, a curve parallel to the axis is twisted around it.

The general study of torsion is complicated because under that type of solicitation the cross section of a piece in general is characterized by two phenomena:

1- Tangential tensions appear parallel to the cross section.

2- When the previous tensions are not properly distributed, which always happens unless the section has circular symmetry, sectional warps appear that make the deformed cross sections not flat.

5 0
3 years ago
Two parallel Rivers (A and B) are separated by confined and unconfined aquifer estimate the RATE of seepage of river A to River
gizmo_the_mogwai [7]

Answer:

Explanation:

A confined aquifer is one that's impermeable and does not allow seepage's  of water through it.

An unconfined aquifer is a body of water that has permeable membranes which allows passage of water through it.

There will be little or no transmission of water trough these bodies of water.

3 0
3 years ago
 what can be done to prevent bridges from collapsing? ( give at least two examples)
ryzh [129]

Explanation:

the owner of the bridge and some workers

4 0
2 years ago
A ramjet operates by taking in air at the inlet, providing fuel for combustion, and exhausting the hot air through the exit. Th
UNO [17]

Answer:

15300 N

Explanation:

\rho_i = Density of air at inlet

\dfrac{m}{t} = Mass flow rate = 60 kg/s

v_i = Inlet velocity = 225 m/s

\rho_o = Density of gas at outlet = 0.25\ \text{kg/m}^3

A_i = Inlet area

A_o = Outlet area = 0.5\ \text{m}^2

Since mass flow rate is the same in the inlet and outlet we have

\rho_iv_iA_i=\rho_ov_oA_o\\\Rightarrow v_o=\dfrac{\dfrac{m}{t}}{\rho_oA_o}\\\Rightarrow v_o=\dfrac{60}{0.25\times 0.5}\\\Rightarrow v_o=480\ \text{m/s}

Thrust is given by

F=\dfrac{m}{t}(v_o-v_i)\\\Rightarrow F=60\times (480-225)\\\Rightarrow F=15300\ \text{N}

The thrust generated is 15300 N.

8 0
3 years ago
Other questions:
  • When you are configuring data deduplication, you must choose a usage type for the volume you are configuring. Which of the follo
    8·1 answer
  • There are two piston-cylinder systems that each contain 1 kg of an idea gas at a pressure of 300 kPa and temperature of 350 K. T
    8·1 answer
  • If you’re designing a new pair of shoes, what are some things you’ll have to think about ??
    6·2 answers
  • The design specifications of a 1.2-m long solid circular transmission shaft require that the angle of twist of the shaft not exc
    15·1 answer
  • WHAT IS THE EFFECT OF ICE ACCRETION ON THE LONGITUDINAL STABILITY OF AN AIRCRAFT?
    8·1 answer
  • The current flow in an NMOS transistor is due to one of the following:
    11·1 answer
  • The distribution of ground shaking around the fault
    5·1 answer
  • I need to solve for d
    11·2 answers
  • What is the placement of a lock out device on an energy isolating device?.
    12·1 answer
  • The toggle (t) flip-flop has one input, clk, and one output, q. on each rising edge of clk, q toggles to the complement of its p
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!