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
lisov135 [29]
2 years ago
9

PythonA group of statisticians at a local college has asked you to create a set of functionsthat compute the median and mode of

a set of numbers, as defined in Section5.4. Define these functions in a module named stats.py. Also include a functionnamed mean, which computes the average of a set of numbers. Each functionshould expect a list of numbers as an argument and return a single number. Eachfunction should return 0 if the list is empty. Include a main function that tests thethree statistical functions with a given list
Engineering
1 answer:
skelet666 [1.2K]2 years ago
3 0

Answer:

  1. def median(l):
  2.    if(len(l) == 0):
  3.       return 0
  4.    else:
  5.        l.sort()
  6.        if(len(l)%2 == 0):
  7.            index = int(len(l)/2)
  8.            mid = (l[index-1] + l[index]) / 2
  9.        else:
  10.            mid = l[len(l)//2]  
  11.        return mid  
  12. def mode(l):
  13.    if(len(l)==0):
  14.        return 0
  15.    mode = max(set(l), key=l.count)
  16.    return mode  
  17. def mean(l):
  18.    if(len(l)==0):
  19.        return 0
  20.    sum = 0
  21.    for x in l:
  22.        sum += x
  23.    mean = sum / len(l)
  24.    return mean
  25. lst = [5, 7, 10, 11, 12, 12, 13, 15, 25, 30, 45, 61]
  26. print(mean(lst))
  27. print(median(lst))
  28. print(mode(lst))

Explanation:

Firstly, we create a median function (Line 1). This function will check if the the length of list is zero and also if it is an even number. If the length is zero (empty list), it return zero (Line 2-3). If it is an even number, it will calculate the median by summing up two middle index values and divide them by two (Line 6-8). Or if the length is an odd, it will simply take the middle index value and return it as output (Line 9-10).

In mode function, after checking the length of list, we use the max function to estimate the maximum count of the item in list (Line 17) and use it as mode.

In mean function,  after checking the length of list,  we create a sum variable and then use a loop to add the item of list to sum (Line 23-25). After the loop, divide sum by the length of list to get the mean (Line 26).

In the main program, we test the three functions using a sample list and we shall get

20.5

12.5

12

You might be interested in
The aluminum rod AB (G 5 27 GPa) is bonded to the brass rod BD (G 5 39 GPa). Knowing that portion CD of the brass rod is hollow
Temka [501]

Answer:

Qcd=0.01507rad

QT= 0.10509rad

Explanation:

The full details of the procedure and answer is attached.

7 0
3 years ago
Ignoring any losses, estimate how much energy (in units of Btu) is required to raise the temperature of water in a 90-gallon hot
Rudik [331]

Answer:

Q=36444.11 Btu

Explanation:

Given that

Initial temperature = 60° F

Final temperature = 110° F

Specific heat of water = 0.999 Btu/lbm.R

Volume of water = 90 gallon

Mass = Volume x density

1\ gallon = 0.13ft^3

Mass ,m= 90 x 0.13 x 62.36 lbm

m=729.62 lbm

We know that sensible heat given as

Q= m Cp ΔT

Now by putting the values

Q= 729.62 x 0.999 x (110-60) Btu

Q=36444.11 Btu

5 0
2 years ago
A_____ transducer is a device that can convert an electronic controller output signal into a standard pneumatic output. A. pneum
makkiz [27]

Answer:

The correct answer is

option C. current to pneumatic (V/P)

Explanation:

A current to pneumatic controller is  basically used to receive an electronic signal from a controller and converts it further into a standard pneumatic output signal which is further used to operate a positioner or control valve. These devices are reliable, robust and accurate.

Though Voltage and current to pressure transducers are collectively called as electro pneumatic tranducers and the only electronic feature to control output pressure in them is the coil.

6 0
3 years ago
Calculate the reluctance of a 4-meter long toroidal coil made of low-carbon steel with an inner radius of 1.75 cm and an outer r
My name is Ann [436]

Answer:

R = 31.9 x 10^(6) At/Wb

So option A is correct

Explanation:

Reluctance is obtained by dividing the length of the magnetic path L by the permeability times the cross-sectional area A

Thus; R = L/μA,

Now from the question,

L = 4m

r_1 = 1.75cm = 0.0175m

r_2 = 2.2cm = 0.022m

So Area will be A_2 - A_1

Thus = π(r_2)² - π(r_1)²

A = π(0.0225)² - π(0.0175)²

A = π[0.0002]

A = 6.28 x 10^(-4) m²

We are given that;

L = 4m

μ_steel = 2 x 10^(-4) Wb/At - m

Thus, reluctance is calculated as;

R = 4/(2 x 10^(-4) x 6.28x 10^(-4))

R = 0.319 x 10^(8) At/Wb

R = 31.9 x 10^(6) At/Wb

8 0
3 years ago
Pls help and solve this problem. I don't have an idea to solve this.
lions [1.4K]

Answer:

MIS HIEVOSTES bbbbbbbbbbbb MIS HUEVOTES

7 0
2 years ago
Other questions:
  • How do you make coke for steel?
    14·1 answer
  • A three-point bending test was performed on an aluminum oxide specimen having a circular cross section of radius 5.0 mm (0.20 in
    13·1 answer
  • The market for college textbooks is illustrated in the graph below. In the market for textbooks, the current price of a textbook
    11·1 answer
  • Explain why the scenario below fails to illustrate an understanding of the importance of metrology. Situation: Natalie is a cali
    6·1 answer
  • A power of 100 kW (105 W) is delivered to the other side of a city by a pair of power lines, between which the voltage is 12,000
    9·1 answer
  • How to update android 4.4.2 to 5.1 if there isnt any update available​
    15·2 answers
  • When an output gear is larger than the input gear the greater ratio is greater than 1 T or F​
    9·1 answer
  • Excessive looseness in steering and suspension components can cause _____
    13·1 answer
  • Is santa real or nah is santa real or nah
    7·2 answers
  • 1. Band saw lower wheel does not require a guard * true or false 2. Band saw upper guide should be adjusted to within 1/8" of th
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!