answer.
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
Elden
28 days ago
5

A group of statisticians at a local college has asked you to create a set of functions that compute the median and mode of a set

of numbers. Define these functions, median and mode, in a module named stats.py. Also include a function named mean, which computes the average of a set of numbers. Each function should expect a list of numbers as an argument and return a single number. Each function should return 0 if the list is empty. Include a main function that tests the three statistical functions using the following list defined in main:List: [3, 1, 7, 1, 4, 10]
Engineering
2 answers:
Mrrafil [271]28 days ago
7 0

Explanation:

def mean(lst):

   if not lst:

       return 0

   total_sum = 0

   for num in lst:

       total_sum += num

   return total_sum / len(lst)

 

def median(lst):

   if not lst:

       return 0

   sorted_samples = sorted(lst.copy())

   if len(sorted_samples) % 2 == 1:

       return sorted_samples[int(len(sorted_samples) / 2)]

   else:

       return (sorted_samples[int(len(sorted_samples) / 2)] + sorted_samples[int(len(sorted_samples) / 2) - 1]) / 2

 

def mode(lst):

   if not lst:

       return 0

   most_frequent = lst[0]

   highest_count = 0

   for num in lst:

       if lst.count(num) >= highest_count:

           highest_count = lst.count(num)

           most_frequent = num

   return most_frequent

 

def main():

   userList = [3, 1, 7, 1, 4, 10]

   print('List:', userList)

   print('Mode:', mode(userList))

   print('Median:', median(userList))

   print('Mean:', mean(userList))

 

main()

Daniel [248]28 days ago
3 0

Answer:

Functions designed to determine the median and mode from a collection of numbers

Explanation:

def median(numbers):

   if not numbers:

       return 0

   numbers.sort()

   middle_idx = len(numbers) / 2

   if len(numbers) % 2 == 1:

       return numbers[middle_idx]

   else:

       return (numbers[middle_idx] + numbers[middle_idx - 1]) / 2

def mean(numbers):

   if not numbers:

       return 0

   numbers.sort()

   total_sum = 0

   for num in numbers:

       total_sum += num

   return total_sum / len(numbers)

def mode(numbers):

   frequency_dict = {}

   for value in numbers:

       curr_value = frequency_dict.get(value, None)

       if curr_value is None:

           frequency_dict[value] = 1

       else:

           frequency_dict[value] = curr_value + 1

   highest_freq = max(frequency_dict.values())

   mode_values = []

   for key in frequency_dict:

       if frequency_dict[key] == highest_freq:

           mode_values.append(key)

   return mode_values

def main():

   print("Mean of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]: ", mean(range(1, 11)))

   print("Mode of [1, 1, 1, 1, 4, 4]:", mode([1, 1, 1, 1, 4, 4]))

   print("Median of [1, 2, 3, 4]:", median([1, 2, 3, 4]))

main()

You might be interested in
At a certain elevation, the pilot of a balloon has a mass of 120 lb and a weight of 119 lbf. What is the local acceleration of g
mote1985 [250]

Response:

1) g=31.87ft/s^2

2)m=120

W=119.64lbf

Clarification:

initial segment

the weight of an object with a specified mass is determined using the equation

W=mg

we need to convert 120lb into slug

m=120lbx1slug/32.147lb=3.733slug

calculating for g

g=W/m

g=119/3.733=31.87ft/s^2

subsequent segment

the mass remains unchanged

m=120lb=3.733slug

Weight

W=3.733slug*32.05ft/s^2=119.64lbf

4 0
13 days ago
An air duct heater consists of an aligned array of electrical heating elements in which the longitudinal and transverse pitches
Kisachek [244]

Answer:

a) q = 7671 W

T0 = 47.6°C

b) ΔP = 202.3 N/m²

P = 58.2 W

c) hDarray = 2 times hD of an isolated element.

Explanation:

see the image for the solution.

4 0
17 days ago
The rate of flow of water in a pump installation is 60.6 kg/s. The intake static gage is 1.22 m below the pump centreline and re
mote1985 [250]

Answer:

The power of the pump is 23.09 kW.

Explanation:

Parameters

gravitational constant, g = 9.81 m/s^2

mass flow rate, \dot{m} = 60.6 kg/s

flow density, \rho = 1000 kg/m^3

efficiency of the pump, \eta = 0.74

output gauge pressure, p_o = 344.75 kPa

input gauge pressure, p_i = 68.95 kPa

cross-sectional area of output pipe, A_o = 0.069 m^2

cross-sectional area of input pipe, A_i = 0.093 m^2

height of discharge, z_o = 1.22 m - 0.61 m = 0.61 m (evaluated at pump’s maximum height of 1.22 m)

input height, z_i = 0 m

hydraulic power of the pump,P =? kW

Initially, the volumetric flow (Q) needs to be determined

Q = \frac{\dot{m}}{\rho}

Q = \frac{60.6 kg/s}{1000 kg/m^3}

Q = 0.0606 m^3/s

Next, compute the velocity (v) for both input and output

v_o = \frac{Q}{A_o}

v_o = \frac{0.0606 m^3/s}{0.069 m^2}

v_o = 0.88 m/s

v_i = \frac{Q}{A_i}

v_i = \frac{0.0606 m^3/s}{0.093 m^2}

v_i = 0.65 m/s

Subsequently, the total head (H) can be calculated

H = (z_o - z_i) + \frac{v_o^2 - v_i^2}{2 \, g} + \frac{p_o - p_i}{\rho \, g}

H = (0.61 m - 0 m) + \frac{{0.88 m/s}^2 - {0.65 m/s}^2}{2 \, 9.81 m/s^2} + \frac{(344.75 Pa-68.95 Pa)\times 10^3}{1000 kg/m^3 \, 9.81 m/s^2}

H = 28.74m

Finally, the computation of pump power is done as follows

P = \frac{Q \, \rho \, g \, H}{\eta}

P = \frac{0.0606 m^3/s \, 1000 kg/m^3 \, 9.81 m/s^2 \, 28.74m}{0.74}

P = 23.09 kW

6 0
28 days ago
An open vat in a food processing plant contains 500 L of water at 20°C and atmospheric pressure. If the water is heated to 80°C,
Mrrafil [271]

Answer:

Volume change percentage is 2.60%

Water level increase is 4.138 mm

Explanation:

Provided data

Water volume V = 500 L

Initial temperature T1 = 20°C

Final temperature T2 = 80°C

Diameter of the vat = 2 m

Objective

We aim to determine percentage change in volume and the rise in water level.

Solution

We will apply the bulk modulus equation, which relates the change in pressure to the change in volume.

It can similarly relate to density changes.

Thus,

E = -\frac{dp}{dV/V}................1

And -\frac{dV}{V} = \frac{d\rho}{\rho}............2

Here, ρ denotes density. The density at 20°C = 998 kg/m³.

The density at 80°C = 972 kg/m³.

Plugging in these values into equation 2 gives

-\frac{dV}{V} = \frac{d\rho}{\rho}

-\frac{dV}{500*10^{-3} } = \frac{972-998}{998}

dV = 0.0130 m³

Therefore, the percentage change in volume will be

dV % = -\frac{dV}{V}  × 100

dV % = -\frac{0.0130}{500*10^{-3} }  × 100

dV % = 2.60 %

Hence, the percentage change in volume is 2.60%

Initial volume v1 = \frac{\pi }{4} *d^2*l(i)................3

Final volume v2 = \frac{\pi }{4} *d^2*l(f)................4

From equations 3 and 4, subtract v1 from v2.

v2 - v1 =  \frac{\pi }{4} *d^2*(l(f)-l(i))

dV = \frac{\pi }{4} *d^2*dl

Substituting all values yields

0.0130 = \frac{\pi }{4} *2^2*dl

Thus, dl = 0.004138 m.

Consequently, the water level rises by 4.138 mm.

8 0
27 days ago
Steam flows at steady state through a converging, insulated nozzle, 25 cm long and with an inlet diameter of 5 cm. At the nozzle
iogann1982 [295]

Answer:

The velocity at exit U_2 is 578.359 m/s

The exit diameter d_e is 1.4924 cm

Explanation:

Provided data includes:

Length of the nozzle L = 25 cm

Inlet diameter d_i = 5 cm

At the nozzle entrance (state 1): Temperature T_1 = 325 °C, Pressure P_1 = 700 kPa, Velocity U_1 = 30 m/s, Enthalpy H_1 = 3112.5 kJ/kg, Volume V_1 = 388.61 cm³/gAt the nozzle exit (state 2): Temperature T_2 = 250 °C, Pressure P_2 = 350 kPa, Velocity U_2, Enthalpy H_2 = 2945.7 kJ/kg, Volume V_2 = 667.75 cm³/g To determine:a. Exit Velocity U_2b. Exit Diameter d_e

a.The Energy Equation can be represented by:ΔH + ΔU² / 2 + gΔz = Q + WAssuming Q = W = Δz = 0Substituting the values yields:

(H_2 - H_1) + (U²_2 - U²_1)  / 2 = 0From which we can derive U_2 = sqrt((2* (H_1 - H_2 )) + U²_1) with the calculations leading to U_2 = sqrt ( 2 * 10^3 * (3112.5 -2945.7) + 900) yielding U_2 = 578.359 m/s

b.

Using mass balance approach, we have U_1 * A_1 / V_1 = U_2 * A_2 / V_2

Here, A = π*d² / 4

This leads to U_1 * d_i² / V_1 = U_2 * d_e² / V_2, thus d_e = d_i * sqrt((U_1 / U_2) * (V_2 / V_1)). Hence, d_e = 5 * sqrt((30 / 578.359) * (667.75 / 388.61)) computes to d_e = 1.4924 cm

6 0
7 days ago
Other questions:
  • A Carnot heat engine receives heat from a reservoir at 900oC at a rate of 800 kJ/min and rejects the waste heat to the ambient a
    13·1 answer
  • Degreasers can be broken down into two main categories
    9·2 answers
  • An overhead 25m-long, uninsulated industrial steam pipe of 100-mm diameter, is routed through a building whose walls and air are
    5·1 answer
  • cubical tank 1 meter on each edge is filled with water at 20 degrees C. A cubical pure copper block 0.46 meters on each edge wit
    6·1 answer
  • A pitfall cited in Section 1.10 is expecting to improve the overall performance of a computer by improving only one aspect of th
    6·1 answer
  • Radioactive wastes are temporarily stored in a spherical container, the center of which is buried a distance of 10 m below the e
    13·1 answer
  • Consider a very long, slender rod. One end of the rod is attached to a base surface maintained at Tb, while the surface of the r
    8·1 answer
  • NEEDS TO BE IN PYTHON:ISBN-13 is a new standard for indentifying books. It uses 13 digits d1d2d3d4d5d6d7d8d910d11d12d13 . The la
    15·1 answer
  • A pipe in a district heating network is transporting over-pressurized hot water (10 atm) at a mass flow of 0.5 kg/s. The pipe is
    14·1 answer
  • A cylinder with a 6.0 in. diameter and 12.0 in. length is put under a compres-sive load of 150 kips. The modulus of elasticity f
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!