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]
3 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]3 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 two shafts of a Hooke’s coupling have their axes inclined at 20°.The shaft A revolves at a uniform speed of 1000 rpm. The sh
lapo4ka [179]

Answer:

33.429 N-m

Explanation:

Given :

Inclination angle of two shaft, α = 20°

Speed of shaft A, N_{A} = 1000 rpm

Mass of flywheel, m = 30 kg

Radius of Gyration, k =100 mm

                                   = 0.1 m

Now we know that for maximum velocity,

\frac{N_{B}}{N_{A}} = \frac{cos\alpha }{1 - sin^{2}\alpha }

\frac{N_{B}}{1000} = \frac{cos20}{1 - sin^{2}20 }

N_{B} = 1064.1 rpm

Now we know

Mass of flywheel, m = 30 kg

Radius of Gyration, k =100 mm

                                   = 0.1 m

Therefore moment of inertia of flywheel, I = m.k^{2}

                                                                      =30 X 0.1^{2}

                                                                     = 0.3 kg-m^{2}

Now torque on the output shaft

T₂ = I x ω

    = 0.3 X 1064.2 rpm

    = 0.3\times \frac{2\pi \times 1064.1}{60}

     = 33.429 N-m

Torque on the Shaft B is 33.429 N-m

4 0
3 years ago
My teacher wants me to build a perpetual motion machine and present it. I know they don't exist, and SHE knows they don't exist
Llana [10]

Answer:

You should do it. it is okay if it does not work because if she knows it does not exist she is using it as a example of how it don't exist

Explanation:

7 0
3 years ago
Read 2 more answers
The concrete canoe team does some analysis on their design and calculates that they need a compressive strength of 860 psi. They
vlada-n [284]

Answer:

874 psi

Explanation:

Given a sample mean (x') = 900,

and a standard error (SE) = 10

At 99% confidence, Z(critical) = 2.58

That gives 99% confidence interval as,

x' ± Z(critical) x SE = 900 ± 2.58 x 10

The value of the lower limit is,

900 - 25.8 = 874.2

≈ 874 psi

8 0
2 years ago
If the contact surface between the 20-kg block and the ground is smooth, determine the power of force F when t = 4 s. Initially,
grigory [225]

Answer:

The power of force F is 115.2 W

Explanation:

Use following formula

Power  = F x V

F_{H} = F cos0

F_{H} = (30) x 4/5

F_{H} = 24N

Now Calculate V using following formula

V = V_{0} + at

V_{0} = 0

a = F_{H} / m

a = 24N / 20 kg

a = 1.2m / S^{2}

no place value in the formula of V

V = 0 + (1.2)(4)

V = 4.8 m/s

So,

Power = F_{H} x V

Power = 24 x 4.8

Power = 115.2 W

3 0
3 years ago
A commercial refrigerator with refrigerant -134a as the working fluid is used to keep the refrigerated space at -30C by rejectin
Mariana [72]

Answer:

a) 0.487

b) refrigeration load = 5.46w

c) cop = 2.24

d)ref load max = 12.43kw

Explanation:

6 0
3 years ago
Read 3 more answers
Other questions:
  • 2.4 kg of nitrogen at an initial state of 285K and 150 kPa is compressed slowly in an isothermal process to a final pressure of
    8·1 answer
  • a triangle is defined by the three vertices. write the following functions of the triangle class assume that the point class has
    7·1 answer
  • Saturated liquid water at 150 F is put under pressure to decrease the volume by 1% while keeping the temperature constant. To wh
    8·1 answer
  • Suppose that tank holds 1% liquid water by volume and 99% vapor water by volume at a temperature of 185oC. What is the quality?
    10·1 answer
  • What are the nominal dimensions for a 1x2 stick of lumber, a 2x4 stick of lumber and a standard sheet of plywood?
    11·1 answer
  • 1. When and why should we use the Pattern option?
    12·1 answer
  • Label each of the line types in the drawing below. ( will not mark you brainlest or whatever if you don't at least try to help)
    11·1 answer
  • Task Three :Write a C++ program to read temperature
    15·1 answer
  • What's the best way to find the load capacity of a crane?
    6·1 answer
  • 'Energy' has the potential to:
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!