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
What does it mean to say that PEER is a data-driven, consumer-centric, and comprehensive system?
Reika [66]

Answer:

have you heard of gnoogle?

Explanation:have you heard of goongle?

3 0
3 years ago
Read 2 more answers
Two streams of air enter a control volume: stream 1 enters at a rate of 0.05 kg / s at 300 kPa and 380 K, while stream 2 enters
alex41 [277]

Answer:

0.08kg/s

Explanation:

For this problem you must use 2 equations, the first is the continuity equation that indicates that all the mass flows that enter is equal to those that leave the system, there you have the first equation.

The second equation is obtained using the first law of thermodynamics that indicates that all the energies that enter a system are the same that come out, you must take into account the heat flows, work and mass flows of each state, as well as their enthalpies found with the temperature.

 

finally you use the two previous equations to make a system and find the mass flows

I attached procedure

5 0
3 years ago
16 . You are turning onto a two-lane road divided by a broken yellow line. You know immediately that:
Over [174]

When a person is turning onto a two-lane road divided by a broken yellow line, you know immediately that you are on a two-way road.

<h3>What is the road about?</h3>

Note that a Yellow centerlines can be seen in roads and it is one that is often used to separate traffic moving in different directions.

Note also that Broken lines can be crossed to allow slower-moving traffic and as such, When a person is turning onto a two-lane road divided by a broken yellow line, you know immediately that you are on a two-way road.

See full question below

You are turning onto a two-lane road divided by a broken yellow line. You know immediately that:

Answers

You are on a two-way road.

You are on a one-way road.

The road is under repair.

You must stay to the left of the broken yellow lines.

Learn more about  two-way road from

brainly.com/question/13123201

#SPJ2

5 0
1 year ago
Draw the internal connections of motor generator set​
Akimi4 [234]

Answer:

tyjtgfjhgk vgjyg7igjccxfb  rt5bshe dgrty5rm nry5ghbhjyrdegbtyr45bh4 cnbfgcb xdftjrnn hdftytr s  jhbgfhtyujt ntj

Explanation:

3 0
3 years ago
What is capillary action?
BARSIC [14]
Capillary action occurs When the adhesion to the walls stronger than dirt cohesive forces between a liquid molecules. the head towards Capillery action will take water in a uniform circular is limited by surface tension and, of course, gravity.
4 0
2 years ago
Other questions:
  • When we utilize a visualization on paper/screen, that visualization is limited to exploring: Group of answer choices Relationshi
    9·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 proposed piping and pumping system has 20-psig static pressure, and the piping discharges to atmosphere 160 ft above the pump.
    8·1 answer
  • 7. A single-pole GFCI breaker is rated at
    9·1 answer
  • Technician a says that diesel engines can produce more power because air in fuel or not mix during the intake stroke. Technician
    9·1 answer
  • Which option identifies the type of engineering technician most likely to be involved in the following scenario?
    9·1 answer
  • Describe how to use cleaning tools and equipment safely and properly
    6·1 answer
  • What is the answer???
    10·1 answer
  • What are the most used electronic tools for electronic works?​
    13·1 answer
  • Why is California a good place for engineers to build suspension bridges?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!