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
A solid circular rod that is 600 mm long and 20 mm in diameter is subjected to an axial force of P = 50 kN The elongation of the
Kay [80]

Answer:

a) V = 0.354

b)  G = 25.34 GPA

Explanation:

Solution:

We first determine Modulus of Elasticity and Modulus of rigidity

Elongation of rod ΔL = 1.4 mm

Normal stress, δ = P/A

Where P = Force acting on the cross-section

A = Area of the cross-section

Using Area, A = π/4 · d²

= π/4 · (0.0020)²  = 3.14 × 10⁻⁴m²

δ = 50/3.14 × 10⁻⁴    = 159.155 MPA

E(long) = Δl/l  = 1.4/600 = 2.33 × 10⁻³mm/mm

Modulus of Elasticity Е = δ/ε

= 159.155 × 10⁶/2.33 × 10⁻³    = 68.306 GPA

Also final diameter d(f) = 19.9837 mm

Initial diameter d(i) = 20 mm

Poisson said that V = Е(elasticity)/Е(long)

= -  <u>( 19.9837 - 20 /20)</u>

        2.33 × 10⁻³                  

= 0.354,

∴ v = 0.354

Also G = Е/2. (1+V)

=  68.306 × 10⁹/ 2.(1+ 0.354)

= 25.34 GPA

⇒ G = 25.34 GPA

5 0
3 years ago
. In one stroke of a reciprocating compressor, helium is isothermally and reversibly compressed in a piston + cylinder from 298
andriy [413]

Answer:

5.7058kj/mole

Explanation:

Please see attachment for step by step guide

5 0
3 years ago
What should you, the worker, be aware of with regard to evacuation procedures at your workplace
Alinara [238K]

Answer:

As a worker, it is important to follow the proper set of instructions or emergency plans during an emergent situation. Not carefully following the rules may result to a bigger problem such as further injury and damage to property.

Explanation:

Evacuation Procedure- This is a step-by-step procedure that people follow in order to safely vacate any building or place. This procedure is applicable to any situation, such as the workplace. This is now called the <em>Workplace Evacuation Procedure. </em>This is very important because there are so many unpredictable situations or events that are happening in the world right now, such as fire or earthquake. This procedure is being done through an evacuation plan.

The awareness of the workers regarding the proper way to evacuate during emergency situation is very important. It will be easier for them to know where to locate the nearest exit route. They will also learn to stop any form of device or equipment that could cause a hazzard during the situation. In case of the hospital, which is also a workplace, the employees will also learn how to assist the patients before themselves. They will also know where to assemble if there's a need to do so.

7 0
3 years ago
Read 2 more answers
A boiler is used to heat steam at a brewery to be used in various applications such as heating water to brew the beer and saniti
Natalija [7]

Answer:

net boiler heat = 301.94 kW

Explanation:

given data

saturated steam = 6.0 bars

temperature = 18°C

flow rate = 115 m³/h = 0.03194 m³/s

heat use by boiler = 90 %

to find out

rate of heat does the boiler output

solution

we can say saturated steam is produce at 6 bar from liquid water 18°C

we know at 6 bar from steam table

hg = 2756 kJ/kg

and

enthalpy of water at 18°C

hf = 75.64 kJ/kg

so heat required for 1 kg is

=hg - hf

= 2680.36 kJ/kg

and

from steam table specific volume of saturated steam at 6 bar is 0.315 m³/kg

so here mass flow rate is

mass flow rate = \frac{0.03194}{0.315}

mass flow rate m = 0.10139 kg/s

so heat required is

H = h × m  

here h is heat required and m is mass flow rate

H = 2680.36  × 0.10139

H =  271.75 kJ/s = 271.75 kW

now 90 % of boiler heat is used for generate saturated stream

so net boiler heat = \frac{H}{0.90}

net boiler heat = \frac{271.75}{0.90}

net boiler heat = 301.94 kW

5 0
3 years ago
5. Name two health problems that fume can cause?<br> a)....<br> b)......
Vlad [161]

Answer:

A) Cancer of the Lungs

B)Larynx and Urinary Tract, as well as nervous system and kidney damage

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • You are working in a lab where RC circuits are used to delay the initiation of a process. One particular experiment involves an
    13·1 answer
  • A computer maintenance company wants to 'capture' the knowledge that employees carry around in their heads by creating a databas
    5·1 answer
  • an adiabatic compressor receives 1.5 meter cube per second of air at 30 degrees celsius and 101 kpa. The discharge pressure is 5
    11·1 answer
  • HELP<br><br><br>the overall width of a part is dimensioned as 3.00 ± 0.02. what is the tolerance
    14·2 answers
  • What is the difference between CNC and NC​
    15·1 answer
  • How did humans create a space suit without ever going. How did we know spaces conditions?
    5·2 answers
  • An energy system can be approximated to simply show the interactions with its environment including cold air in and warm air out
    6·1 answer
  • the social dilemma and coded bias documentary compare and contrast (goods and bad) they may have on future technology developmen
    12·1 answer
  • Hi gospelgamer10 lol
    9·2 answers
  • A red circle and diagonal slash on a sign means that:.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!