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
Define the terms (a) thermal conductivity, (b) heat capacity and (c) thermal diffusivity
IceJOKER [234]

Explanation:

<u>(a)</u>

<u>The measure of material's ability to conduct thermal energy (heat) is known as thermal conductivity.</u> For examples, metals have high thermal conductivity, it means that they are very efficient at conducting heat.<u> The SI unit of heat capacity is W/m.K.</u>

The expression for thermal conductivity is:

q=-\kappa \bigtriangledown T

Where,

q is the heat flux

\kappa is the thermal conductivity

\bigtriangledown T is the temperature gradient.

<u>(b)</u>

<u>Heat capacity for a substance is defined as the ratio of the amount of energy required to change the temperature of the substance and the magnitude of temperature change. The SI unit of heat capacity is J/K.</u>

The expression for Heat capacity is:

C=\frac{E}{\Delta T}

Where,

C is the Heat capacity

E is the energy absorbed/released

\Delta T is the change in temperature

<u>(c)</u>

<u>Thermal diffusivity is defined as the thermal conductivity divided by specific heat capacity at constant pressure and its density. The Si unit of thermal diffusivity is m²/s.</u>

The expression for thermal diffusivity is:

\alpha=\frac{\kappa}{C_p \times \rho}

Where,

\alpha is thermal diffusivity

\kappa is the thermal conductivity

C_p is specific heat capacity at constant pressure

\rho is density

6 0
3 years ago
The difference between an initial condition and a boundary condition for conduction in a solid is:___________
leva [86]

Answer:

c. an initial condition specifies the temperature at the start of the problem and a boundary condition provides information about temperatures on the boundaries.

Explanation:

Conduction refers to the transfer of thermal energy or electric charge as a result of the movement of particles. When the conduction relates to electric charge, it is known as electrical conduction while when it relates to thermal energy, it is known as heat conduction.

In the process of heat conduction, thermal energy is usually transferred from fast moving particles to slow moving particles during the collision of these particles. Also, thermal energy is typically transferred between objects that has different degrees of temperature and materials (particles) that are directly in contact with each other but differ in their ability to accept or give up electrons.

Any material or object that allow the conduction (transfer) of electric charge or thermal energy is generally referred to as a conductor. Conductors include metal, steel, aluminum, copper, frying pan, pot, spoon etc.

Hence, the difference between an initial condition and a boundary condition for conduction in a solid is that an initial condition specifies the temperature at the start of the problem and a boundary condition provides information about temperatures on the boundaries.

7 0
3 years ago
A beam has been fixed to the floor by the pin at B and the roller at A as shown in figure 1 below.​
ahrayia [7]
What figure below???
3 0
3 years ago
6. Driving with parking lights only (in place of headlights) is against the law. A. True B. False
trasher [3.6K]

Answer:

B false it is illegal to only have got fog lights on though and bright headlights because it can distract other drivers going last and if the y are distracted then that will cause a collision

Hope this helps :)

Explanation:

4 0
3 years ago
Read 2 more answers
1: asha started abusness with 30.000
svetoff [14.1K]

Answer:

Explanation:adrive with visual acutity of 20/30 can just decipher asing adistance 20ft from asing determine the maximum destance from the sing which drivers with the flowing visual acuities will able to see the same sing 20/15 20/50

4 0
3 years ago
Other questions:
  • Briefly describe the purpose of specifying boundary conditions.
    7·1 answer
  • Which of the following statements define drug abuse
    7·1 answer
  • Create a program named IntegerFacts whose Main() method declares an array of 10 integers.Call a method named FillArray to intera
    12·1 answer
  • How do I calculate the gear ratio​
    6·1 answer
  • You are traveling along an interstate highway at 32.0 m/s (about 72 mph) when a truck stops suddenly in front of you. You immedi
    11·1 answer
  • A lighthouse built at sea level is 170ft high from its top , the angle of depression of a buoy is 29 degrees . Find the distance
    10·1 answer
  • When handling chemicals and solvents, technicians are recommended to
    10·2 answers
  • Why it is important to prepare first the materials and tools carpentry before doing the tasks?​
    6·2 answers
  • Which of the following addresses future implications of design and process decisions?
    5·1 answer
  • Which of the given strategies is specifically a competitive advantage sustainment strategy?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!