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 Permanent Electrical Safety Device (PESD) becomes a real safety device only after it is installed as part of a Lockout/Tagout
Nostrana [21]

Answer:

True

Explanation:

Permanent electrical safety devices (PESD) acts as a layer of protection between the electrical worker and the hazardous voltage.

Permanent electrical safety devices (PESDs) are deployed to reduce the risks in isolating electrical energy.

Electrical safety can be improved if a worker determines a zero electrical energy state irrespective of any voltage exposure to themselves.

The given statement is true

7 0
3 years ago
Describe a project in which you would use a pleater, ruffling foot, or gathering foot. Explain each of these tools and choose th
WITCHER [35]

A project that requires using a pleater, a ruffling foot, or a gathering foot is the creation of a dress.

A pleater, a ruffling foot, and a gathering foot are all accessories for sewing machines or machines themselves that help fashion designers to give the fabric a different shape or texture, and therefore create unique pieces.

  • Pleater: This tool includes multiple needles that go through the fabric to create multiple pleats
  • Ruffling foot: This is usually an accessory for sewing machines to create ruffles
  • Gathering foot: This tool is used to create gathers in fabric, these differ from ruffles because they are smaller and more subtle than ruffles

All of the tools can be used in the creation of a dress, for example, a pleater can be used in the top section of the dress to give it a nice texture and make it different from the skirt. In the same way, others such as the ruffling foot or the gathering foot can be used in the sleeves of the dress.

Learn more in: brainly.com/question/24702927

8 0
3 years ago
Do not ________________ a tool. *<br> -clean up<br> -force<br> -stop<br> -unplug
rodikova [14]
Answer:Unplug or force?
4 0
4 years ago
Read 2 more answers
The Eads Bridge, which crosses the Mississippi River near St Louis, Missouri, was one of the first all steel bridges built in th
MrMuchimi

Answer: At 520 feet between the piers, the center arch of Eads Bridge was the longest rigid span ever built at the time of its construction (only a few suspension bridges had longer spans).

Explanation:

5 0
3 years ago
determine the position d of the 6- kn load so that the average normal stress in each rod is the same.
Zinaida [17]

The load is placed at distance 0.4 L from the end of $$12 \mathrm{~mm}^{2} $ area.

<h3>What is meant by torque?</h3>

The force that can cause an object to rotate along an axis is measured as torque. Similar to how force accelerates an item in linear kinematics, torque accelerates an object in an angular direction. A vector quantity is torque.

Let the beam is of length L

Now the stress on both the end is the same now we can say that torque on the beam due to two forces must be zero

$N_1 * x=N_2 *(L-x)$

also, we know that stress at both ends are same

$\frac{N_1}{12}=\frac{N_2}{8}$

$2 * N_1=3 * N_2$

Now from two equations we have

$\frac{3}{2} N_2 * x=N_2 *(L-x)

solving the above equation we have

$x=\frac{2}{5} L

so the load is placed at distance 0.4 L from the end of $$12 \mathrm{~mm}^{2} $ area.

The complete question is:

47. the beam is supported by two rods ab and cd that have cross-sectional areas of $$12mm^2 and $$8mm^2, respectively. determine the position d of the 6-kn load so that the average normal stress in each rod is the same.

To learn more about torque refer to:

brainly.com/question/20691242

#SPJ4

7 0
2 years ago
Other questions:
  • The current entering the positive terminal of a device is i(t)= 6e^-2t mA and the voltage across the device is v(t)= 10di/dtV.
    6·1 answer
  • Define potato.<br> 10 pts
    13·2 answers
  • The gear lube level is being checked in a manual transmission. Technician A says it should run out when the plug is removed. Tec
    6·1 answer
  • A developer has requested permission to build a large retail store at a location adjacent to the intersection of an undivided fo
    5·1 answer
  • Plane wall of material A with internal heat generation is insulated on one side and bounded by a second wall of material B, whic
    10·1 answer
  • A fair die is thrown, What is the probability gained if you are told that 4 will
    12·1 answer
  • The importance of reading a circuit diagram to interpret a wiring diagram?
    5·1 answer
  • IM JI Suneou uo mm
    12·1 answer
  • In regards to bridges, what innovation took place in the 60's ?
    6·1 answer
  • 8. Removing damage by tapping it out with a hammer
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!