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
Name the variable in this experiment
taurus [48]
You have to show the story or experiment so we know
7 0
3 years ago
For the SR-latch below high levels of Set and Reset result in Q= 1 and 0, respectively. The next state is unknown when both inpu
dusya [7]

Answer:

hello your question lacks the required image attached to this answer is the image required

answer :  NOR1(q_) wave is complementary to NOR2(q)

Explanation:

Note ; NOR 2 will be addressed as q in the course of this solution while NOR 1 will be addressed as q_

Initial state is unknown i.e q = 0 and q_= 1

from the diagram the waveform reset and set

= from 0ns to 20ns reset=1 and set=0.from the truth table considering this given condition q=0 and q_bar=1 while  

from 30ns to 50ns reset=0 and set=1.from the truth table considering this condition q=1 and q_bar=1.so from 35ns also note there is a delay of 5 ns for the NOR gate hence the NOR 2 will be higher ( 1 )

From 50ns to 65ns both set and reset is 0.so NOR2(q)=0.

From 65 to 75 set=1 and reset=0,so our NOR 2(q)=1 checking from the truth table

also  from 75 to 90 set=1 and reset=1 , NOR2(q) is undefined "?" and is mentioned up to 95ns.

since q_ is a complement of q, then NOR1(q_) wave is complementary to NOR2(q)

3 0
3 years ago
Tech A says that serviceable wheel bearings can be repacked by removing the dust cap, filling it with grease, and reinstalling i
rewona [7]

Serviceable wheel bearings can be repacked by removing the dust cap and the cotter pin must be replaced with a new one every time it is removed. Therefore, both Tech A and B are correct.

Sealed bearing assemblies are typically prefilled with lubricant. They also make a more reliable and consistent installation process due to the fact that every into comes preset at the proper clearance.

Furthermore, the serviceable wheel bearings can be repacked by removing the dust cap, filling it with grease, and reinstalling it. Also, cotter pin must be replaced with a new one every time it is removed.

Therefore, both tech A and B are correct.

Read related link on:

brainly.com/question/16612086

8 0
2 years ago
Of the core elements of successful safety and health programs,management leadership,worker participation and what else directly
ch4aika [34]
I think it would definitely be dinvi and the ghosts just because I really relate to that story
7 0
3 years ago
Which of the following is NOT a common problem or mistake with blueprints?
Nikitich [7]

Answer:

illegible.writng

Explanation:

am I right

3 0
3 years ago
Other questions:
  • Refrigerant 22 undergoes a constant-pressure process within a piston–cylinder assembly from saturated vapor at 3.5 bar to a fina
    8·1 answer
  • A wastewater treatment plant has two primary clarifiers, each 20m in diameter with a 2-m side-water depth. the effluent weirs ar
    8·1 answer
  • Emergency plans are being formulated so that rapid action can be taken in the event of an equipment failure. It is predicted tha
    12·2 answers
  • After cutting a PVC pipe you should use a<br> to debure the pipe
    7·1 answer
  • - What will happen if high voltage from the HV battery or motor-generator is shorting to frame ground?
    6·1 answer
  • 10 10 10 10 10 10 10 10 10 10
    6·2 answers
  • The signal propagation time between two ground stations in a synchronous satellite link is about millisecond is​
    11·1 answer
  • In this unit, you looked at modern vehicle technology and the ad-
    11·1 answer
  • When a tensile specimen is stretched in the plastic region to an engineering strain of 0.2, calculate the amount of cold work pe
    15·1 answer
  • If I have a scaffold that is 83' tall, and the base of my scaffold is 5' wide least base dimension, then I am allowed to space m
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!