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
Please answer fast. With full step by step solution.​
lina2011 [118]

Let <em>f(z)</em> = (4<em>z </em>² + 2<em>z</em>) / (2<em>z </em>² - 3<em>z</em> + 1).

First, carry out the division:

<em>f(z)</em> = 2 + (8<em>z</em> - 2) / (2<em>z </em>² - 3<em>z</em> + 1)

Observe that

2<em>z </em>² - 3<em>z</em> + 1 = (2<em>z</em> - 1) (<em>z</em> - 1)

so you can separate the rational part of <em>f(z)</em> into partial fractions. We have

(8<em>z</em> - 2) / (2<em>z </em>² - 3<em>z</em> + 1) = <em>a</em> / (2<em>z</em> - 1) + <em>b</em> / (<em>z</em> - 1)

8<em>z</em> - 2 = <em>a</em> (<em>z</em> - 1) + <em>b</em> (2<em>z</em> - 1)

8<em>z</em> - 2 = (<em>a</em> + 2<em>b</em>) <em>z</em> - (<em>a</em> + <em>b</em>)

so that <em>a</em> + 2<em>b</em> = 8 and <em>a</em> + <em>b</em> = 2, yielding <em>a</em> = -4 and <em>b</em> = 6.

So we have

<em>f(z)</em> = 2 - 4 / (2<em>z</em> - 1) + 6 / (<em>z</em> - 1)

or

<em>f(z)</em> = 2 - (2/<em>z</em>) (1 / (1 - 1/(2<em>z</em>))) + (6/<em>z</em>) (1 / (1 - 1/<em>z</em>))

Recall that for |<em>z</em>| < 1, we have

\displaystyle\frac1{1-z}=\sum_{n=0}^\infty z^n

Replace <em>z</em> with 1/<em>z</em> to get

\displaystyle\frac1{1-\frac1z}=\sum_{n=0}^\infty z^{-n}

so that by substitution, we can write

\displaystyle f(z) = 2 - \frac2z \sum_{n=0}^\infty (2z)^{-n} + \frac6z \sum_{n=0}^\infty z^{-n}

Now condense <em>f(z)</em> into one series:

\displaystyle f(z) = 2 - \sum_{n=0}^\infty 2^{-n+1} z^{-(n+1)} + 6 \sum_{n=0}^\infty z^{-n-1}

\displaystyle f(z) = 2 - \sum_{n=0}^\infty \left(6+2^{-n+1}\right) z^{-(n+1)}

\displaystyle f(z) = 2 - \sum_{n=1}^\infty \left(6+2^{-(n-1)+1}\right) z^{-n}

\displaystyle f(z) = 2 - \sum_{n=1}^\infty \left(6+2^{2-n}\right) z^{-n}

So, the inverse <em>Z</em> transform of <em>f(z)</em> is \boxed{6+2^{2-n}}.

4 0
3 years ago
What is the answer of this question please tell me <br><br>dadada please please​
charle [14.2K]

lol i neeeeeeeeeeeeeeeeeeeeeeeed pointssssssssssssssss

6 0
3 years ago
james wants to qualify for icp are and licensure. Which degree would be required in order to qualify for a two year master of ar
ololo11 [35]

Answer:

A degree in architecture with 60 credit hours.

Explanation:

The requirements need for a student to qualify for a two year master of architecture degree are;

  • 60 credit hours in architecture
  • Complete 60 credit hours in related area of profession such as; planning, landscape architecture ,public health and others.
  • 45 credit hours in architecture course at the level of 500/600
4 0
3 years ago
In Lab 7, we worked through a program that displayed the homeless shelter occupancy over time. The same approach can be used for
Bezzdna [24]

Answer:

Explanation:

The python code to generate this is quite simple to run.

i hope you understand everything written here, you can as well try out other problems to understand better.

First to begin, we import the package;

Code:

import pandas as pd

import matplotlib.pyplot as plt

name = input('Enter name of the file: ')

op = input('Enter name of output file: ')

df = pd.read_csv(name)

df['Date'] = pd.to_datetime(df["Date"].apply(str))

plt.plot(df['Date'],df['Absent']/(df['Present']+df['Absent']+df['Released']),label="% Absent")

plt.legend(loc="upper right")

plt.xticks(rotation=20)

plt.savefig(op)

plt.show()

This should generate the data(plot) as seen in the uploaded screenshot.

thanks i hope this helps!!!

6 0
3 years ago
A large increase in elevation can cause a carbureted engine to run ________ if not properly adjusted for the altitude. a Rich b
mash [69]

Answer:

B - Poor

Explanation:

As you get higher up, There is less oxygen which causes the engine to create less power.

3 0
3 years ago
Other questions:
  • A composite wall consists of 20 mm thick steel plate backed by insulation brick (k = 0.39 W/mK) of 50 cm thickness and overlaid
    6·1 answer
  • Members of the student council have been asked by their
    5·1 answer
  • A closed system undergoes a process in which work is done on the system and the heat transfer Q occurs only at temperature Tb. F
    8·1 answer
  • A piston-cylinder device contains 0.8 kg of steam at 300°C and 1 MPa. Steam is cooled at constant pressure until one-half of the
    9·1 answer
  • The uniform crate has a mass of 50 kg and rests on the cart having an inclined surface. Determine the smallest acceleration that
    10·1 answer
  • What structure was created to help prevent shipwrecks?
    9·1 answer
  • : A cyclical load of 1500 lb is to be exerted at the end of a 10 in. long aluminium beam (see Figure below). The bar must surviv
    6·1 answer
  • How long does it take to get a master's degree in Mechanical engineering?
    12·1 answer
  • For a bolted assembly with eight bolts, the stiffness of each bolt is kb = 1.0 MN/mm and the stiffness of the members is km = 2.
    14·1 answer
  • Problem 2
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!