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
Tech B says that long-term fuel trims that are positive means that the PCM is leaning out the fuel mixture from the base pulse-w
Masteriza [31]

Answer:

include a pictrue and mark me brainliest

Explanation:

4 0
2 years ago
Read 2 more answers
For the R function shown below(Attachment):
Virty [35]

Answer:

The given function will return an integer in term of j on each iteration of while loop. However, it is noted that this program has some syntax error. The complete code executed in an online R compiler with explanation is given below

Explanation:

def<-function(j){

               k=0;

               i=1;

               while (i<j**3) #j raise to power 3

                   {

               

                   k<-k+1;#k=k+1

                   i <- i*2;#i=i*2

                   print(k);#

               }

 

    }

 def(6)# if you pass the value 6 to function def(j)

5 0
2 years ago
what is the expected life 1 inch diameter bar machined from AISI 1020 CD Steel is subjected to alternating bending stress betwee
Alexeev081 [22]

Answer:

1.287 *10⁷ cycles.

Explanation:

See attached pictures.

3 0
3 years ago
A composite shaft with length L = 46 in is made by fitting an aluminum sleeve (Ga = 5 x 10^3 ksi) over a
Xelga [282]

Answer:

Explanation:

Given the data in the question;

L = 46 in

Ga = 5 × 10³ ksi

Gs = 11 × 10³ ksi

Outside diameter da = 5 in

ds = 4 in

Tb = 3 kip.in

Now,

Ja = polar moment of Inertia of Aluminum;

Ja ⇒ π/32( 5⁴ - 4⁴ ) = π/32( 625 - 256 ) = π/32( 369 ) in^u

Js = polar moment of inertia of steel

Js ⇒ π/32 ds⁴ = π/32( 4⁴ ) = π/32( 256 )

Ta is torque transmitted by Aluminum  

Ts is torque transmitted by steel  

{composite member }

T = Ta + Ts ------ let this be equation m1

Now, we use the relation;

T/J = G∅/L

JG∅ = TL

∅ = TL/GJ

so, for aluminum rod ∅_{alu = TaLa/GaJa

for steel rod ∅_{steel = TsLs/GsJs

but we know that, ∅a = ∅s = ∅_B

so

[TaLa/GaJa]  =  [TsLs/GsJs]

also, we know that, La = Ls = L

∴ [Ta/GaJa]  =  [Ts/GsJs]

we solve for Ta

TaGsJs = TsGaJa  

Ta = TsGaJa / GsJs

we substitute

Ta = [Ts(5 × 10³)( π/32( 369) )] / [ (11 × 10³)( π/32( 256 ) ) ]

Ta = 0.66Ts

now, we substitute 0.66Ts for Ta and 3 for T in equation 1

T = Ta + Ts

3 = 0.66Ts + Ts

3 = 1.66Ts

Ts = 3 / 1.66

Ts = 1.8072 ≈ 1.81 kip-in

so

∅_{steel = TsLs / GsJs

we substitute

∅_{steel = (1.81 × 46 ) / ( 11 × 10³ × π/32( 256 ) )

∅_{steel = 83.26 / 276460.1535

∅_{steel  = 0.000301

∅_{steel = 3.01 × 10⁻⁴ rad

so

∅_{steel = ∅_B = 3.01 × 10⁻⁴ rad

Therefore, the magnitude of the angle of twist at end B is 3.01 × 10⁻⁴  rad

5 0
2 years ago
This question allows you to practice proving a language is non-regular via the Pumping Lemma. Using the Pumping Lemma (Theorem 1
Ulleksa [173]

Answer:

<em>L is not a regular language with formal proofs  </em>

Explanation:

<em>(a) To prove that L is not a regular language, we will use a proof by contradiction. the assumption entails  that L is a regular language. Then by the Pumping Lemma for Regular Languages, </em>

<em>there exists a pumping length p for L such that for any string s ∈ L where |s| ≥ p, </em>

<em>s = xyz subject to the following conditions: </em>

<em>(a) |y| > 0 </em>

<em>(b) |xy| ≤ p, and </em>

<em>(c) ∀i > 0, xyi </em>

<em>z ∈ L</em>

<em />

<em>(b) To determine that L is not a regular language, we mke use of proof by contradiction.  lets assume, that L is regular. Then by the Pumping Lemma for Regular Languages, it states also,</em>

<em>The pumping length, p for L such that for any string s ∈ L where |s| ≥ p, s = xyz subject  to the condtions as follows : </em>

<em>(a) |y| > 0 </em>

<em>(b) |xy| ≤ p, and </em>

<em>(c) ∀i > 0, xyi </em>

<em>z ∈ L. </em>

<em>Choose s = 0p10p </em>

<em>. Clearly, |s| ≥ p and s ∈ L. By condition (b) above, it follows is shown. by the first condition x and y are zeros.</em>

<em>for some  k > 0. Per (c), we can take i = 0 and the resulting string will still be in L. Thus,  xy0 </em>

<em>z should be in L. xy0 </em>

<em>z = xz = 0(p−k)10p </em>

<em>It is shown that is is  not in L. This is a  contraption with the pumping lemma.  our assumption that L is regular is  incorrect, and L is not a regular language</em>

6 0
3 years ago
Other questions:
  • Marcelo es muy bueno resolviendo adivinanzas y acertijos. Por eso, estaba totalmente disgustado cuando se dio cuenta de que no e
    12·1 answer
  • The outer surface temperature of a glass filled with iced water may drop below the dew-point temperature of the surrounding air,
    5·1 answer
  • For a bronze alloy, the stress at which plastic deformation begins is 297 MPa and the modulus of elasticity is 113 GPa. (a) What
    7·1 answer
  • What are 5 advantages of wood as a manufacturing or construction​
    12·1 answer
  • Steam enters a heat exchanger at a pressure of 1.5 bar and a temperature of 400°C with a mass flow rate of 0.05 kg/s and exits a
    11·1 answer
  • An Otto cycle with air as the working fluid has a compression ratio of 8.2. Under cold air standard conditions, what is the ther
    14·1 answer
  • your friend's parents are worried about going over their budget for th month. Which expense would you suggest is NOT a need?
    9·1 answer
  • Which of the following describes a tropical grassland environment?
    6·2 answers
  • What is one of the most common ways in which workers get hurt around machines?
    14·1 answer
  • What is a beta testing ?
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!