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 bus travels the 100 miles between A and B at 50 mi/h and then another 100 miles between B and C at 70 mi/h.
stira [4]

Answer:

c. less than 60 mi/h

Explanation:

To calculate the average speed of the bus, we need to calculate the total distance traveled by the bus, as well as the total time of travel of the bus.

Total Distance Traveled = S = 100 mi + 100 mi

S = 200 mi

Now, for total time, we calculate the times for both speeds from A to b and then B to C, separately and add them.

Total Time = t = Time from A to B + Time from B to C

t = (100 mi)/(50 mi/h) + (100 mi)(70 mi/h)

t = 2 h + 1.43 h

t = 3.43 h

Now, the average speed of bus will be given as:

Average Speed = V = S/t

V = 200 mi/3.43 h

<u>V = 58.33 mi/h</u>

It is clear from this answer that the correct option is:

<u>c. less than 60 mi/h</u>

7 0
3 years ago
The 10 foot wide circle quarter gate AB is articulated at A. Determine the contact force between the gate and the smooth surface
slamgirl [31]

Answer:

F = 641,771.52 \dfrac{lb-ft}{s^2}

Explanation:

Given that

R=8 ft

Width= 10 ft

We know that hydro statics force given as

  F=ρ g A X

ρ is the density of fluid

A projected area on vertical plane

X is distance of center mass of projected plane from free surface of water.

Here

X=8/2  ⇒X=4 ft

A=8 x 10=80  ft^2

So now putting the values

F=ρ g A X

F=62.4(32.14)(80)(4)

F = 641,771.52 \dfrac{lb-ft}{s^2}

   

4 0
4 years ago
An array of electronic chips is mounted within a sealedrectangular enclosure, and colling is implemented by attaching analuminum
Licemer1 [7]

Answer:

Base temperature is 46.23 °C

Explanation:

I've attached explanations

6 0
3 years ago
What is the built-in pollution control system in an incinerator called
Kobotan [32]

Explanation:

hbyndbnn☝️

7 0
3 years ago
Identify the right components for gsm architecture that consists of the hardware or physical equipment such as digital signal pr
sergiy2304 [10]

The right components for gsm architecture that consists of the hardware or physical equipment such as digital signal processors, radio transceiver, display, battery, case and sim card is the Mobile station.

<h3>What are the 4 main components?</h3>

In GSM, a cell station includes 4 fundamental additives: Mobile termination (MT) - gives not unusualplace features consisting of: radio transmission and handover, speech encoding and decoding, blunders detection and correction, signaling and get right of entry to to the SIM. The IMEI code is connected to the MT.

Under the GSM framework, a cell tele cell smartphone is called a Mobile Station and is partitioned into  wonderful additives: the Subscriber Identity Module (SIM) and the Mobile Equipment (ME).

Read more about the mobile station:

brainly.com/question/917245

#SPJ4

6 0
2 years ago
Other questions:
  • You find a publication from a research laboratory that identifies a new catalyst for ammonia synthesis. The article contains the
    6·1 answer
  • Steam undergoes an isentropic compression in an insulated piston–cylinder assembly from an initial state where T1 5 1208C, p1 5
    15·1 answer
  • True or False:<br> Less than 2% of the U.S. population make their living producing food and fiber.
    13·1 answer
  • What is the temperature dependency of the electrical conductivity for metals and semiconductors??
    6·1 answer
  • In which forms do MOST of the Sun's energy reach Earth's surface?
    15·1 answer
  • 2. It is a measuring instrument used to record the amount of
    15·1 answer
  • Which of the following is described as a way engineers can test and investigate how things should be under certain circumstances
    8·1 answer
  • A 1020 Cold-Drawn steel shaft is to transmit 20 hp while rotating at 1750 rpm. Calculate the transmitted torque in lbs. in. Igno
    6·1 answer
  • In a series circuit, resistance is the simple _____ of all resistors in the circuit.
    5·1 answer
  • How frequently should vehicle registration be renewed?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!