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
Arisa [49]
4 years 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:
emmasim [6.3K]4 years ago
7 0

Explanation:

def mean(lst):

   if not lst:

       return 0

   total = 0

   for num in lst:

       total + = num

   return total / len(lst)

 

def median(lst):

   if not lst:

       return 0

   samples = sorted(lst.copy())

   if len(samples) % 2 == 1:

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

   else:

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

 

def mode(lst):

   if not lst:

       return 0

   result = lst[0]

   count = 0

   for num in lst:

       if lst.count(num) >= count:

           count = lst.count(num)

           result = num

   return result

 

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()

iVinArrow [24]4 years ago
3 0

Answer:

Functions to create a median and mode of a set of numbers

Explanation:

def median(list):

   if len(list) == 0:

       return 0

   list.sort()

   midIndex = len(list) / 2

   if len(list) % 2 == 1:

       return list[midIndex]

   else:

       return (list[midIndex] + list[midIndex - 1]) / 2

def mean(list):

   if len(list) == 0:

       return 0

   list.sort()

   total = 0

   for number in list:

       total += number

   return total / len(list)

def mode(list):

   numberDictionary = {}

   for digit in list:

       number = numberDictionary.get(digit, None)

       if number == None:

           numberDictionary[digit] = 1

       else:

           numberDictionary[digit] = number + 1

   maxValue = max(numberDictionary.values())

   modeList = []

   for key in numberDictionary:

       if numberDictionary[key] == maxValue:

           modeList.append(key)

   return modeList

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
Answer every question of this quiz
Reil [10]

I'd say number 4, number 3 looks like an exhaust valve

5 0
4 years ago
If the dry-bulb temperature is 95°F and the wet-bulb temperature is also 78°F, what is the relative humid- ity? What is the dew
Sidana [21]

Answer:

Relative humidity 48%.

Dew point 74°F

humidity ratio 118 g of moisture/pound of dry air

enthalpy 41,8 BTU per pound of dry air

Explanation:

You can get this information from a Psychrometric chart for water, like the one attached.

You enter the chart with dry-bulb and wet-bulb temperatures (red point in the attachment) and following the relative humidity curves you get approximately 48%.

To get the dew point you need to follow the horizontal lines to the left scale (marked with blue): 74°F

for the humidity ratio you need to follow the horizontal lines but to the rigth scale (marked with green): 118 g of moisture/pound of dry air

For enthalpy follow the diagonal lines to the far left scale (marked with yellow): 41,8 BTU per pound of dry air

5 0
3 years ago
4.
Roman55 [17]

Answer:

D

Explanation:

6 0
3 years ago
Read 2 more answers
A venturi meter is to be installed in a 63 mm bore section of a piping system to measure the flow rate of water in it. From spac
Alex Ar [27]

Answer:

Throat diameter d_2=28.60 mm

Explanation:

 Bore diameter d_1=63mm  ⇒A_1=3.09\times 10^{-3} m^2

Manometric deflection x=235 mm

Flow rate Q=240 Lt/min⇒ Q=.004\frac{m^3}{s}

Coefficient of discharge C_d=0.8

We know that discharge through venturi meter

 Q=C_d\dfrac{A_1A_2\sqrt{2gh}}{\sqrt{A_1^2-A_2^2}}

h=x(\dfrac{S_m}{S_w}-1)

S_m=13.6 for Hg and S_w=1 for water.

h=0.235(\dfrac{13.6}{1}-1)

h=2.961 m

Now by putting the all value in

Q=C_d\dfrac{A_1A_2\sqrt{2gh}}{\sqrt{A_1^2-A_2^2}}

0.004=0.8\times \dfrac{3.09\times 10^{-3} A_2\sqrt{2\times 9.81\times 2.961}}{\sqrt{(3.09\times 10^{-3})^2-A_2^2}}

A_2=6.42\times 10^{-4} m^2

 ⇒d_2=28.60 mm

So throat diameter d_2=28.60 mm

     

4 0
3 years ago
Led test lights are used to test circuits that include controllers and computers. True or false
Marianna [84]

Answer:

True

Explanation:

An LED test light is a piece of electronic test equipment used to determine the presence of electricity in a piece of equipment under test, making this statement true.

3 0
2 years ago
Other questions:
  • A certain full-wave rectifier has a peak output voltage of 30 V. A 50 mF capacitor-input filter is connected to the rectifier. C
    6·1 answer
  • What are factor of safety for brittle and ductile material
    5·1 answer
  • Compute the estimated actual endurance strength (Sn) for SAE 3140 OQT 1000 steel bar with a rectangular cross section of w-30 mm
    6·1 answer
  • Who want to 1v1 lol unblocked games 76 with me
    5·2 answers
  • Which term refers to the impurities found during the welding process ?
    15·1 answer
  • In a ground-water basin of 12 square miles, there are two aquifers: an upper unconfined aquifer 500 ft in thickness and a lower
    12·1 answer
  • A carbon resistor has a resistance of 976 ohms at 0 degrees C. Determine its resistance at 89 degrees C​
    6·1 answer
  • Employers are not required to have, specially posted OSHA notice in from informing employees of their protections in obligations
    8·1 answer
  • 1. How is high-speed internet typically transmitted around the world? over telephone wires b. through fiber optic cables c. beam
    9·2 answers
  • How far away must a pwc stay from anyone being towed behind another vessel?.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!