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
Which of the following is an example of a hardwood? A maple B spruce C pine D fir
bearhunter [10]

Answer:

A. Maple

Explanation:

Maple is a hardwood.

Hope that helps!

7 0
2 years ago
The cars of a roller-coaster ride have a speed of 19.0 km/h as they pass over the top of the circular track. Neglect any frictio
Dmitrij [34]

Complete Question

The cars of a roller-coaster ride have a speed of 19.0 km/h as they pass over the top of the circular track. Neglect any friction and calculate their speed v when they reach the horizontal bottom position. At the top position, the radius of the circular path of their mass centers is 21 m, and all six cars have the same mass.V = -18 m What is v?X km/h

Answer:

v=23.6m/s

Explanation:

Velocity v_c=18.0km/h

Radius r=21m

initial velocity uu=19=>5.27778

Generally the equation for Angle is mathematically given by

\theta=\frac{v_c}{2r}

\theta=\frac{18}{2*21}

\theta=0.45

\theta=25.7831 \textdegree

Generally

Height of mass

h=\frac{rsin\theta}{\theta}

h=\frac{21sin25.78}{0.45}

h=20.3m

Generally the equation for Work Energy is mathematically given by

0.5mv_0^2+mgh=0.5mv^2

Therefore

v=\sqrt{u^2+2gh}

v=\sqrt{=5.27778^2+2*9.81*20.3}

v=23.6m/s

3 0
3 years ago
Identify three material considerations an engineer would need to consider when working on a design process.
Anika [276]

Answer:

Three material considerations are;

1. Identify and appraise the attainment of the goal of the with the design specification

2. Ascertain the required load the product being designed will experience and the suitability of the design specification to that load

3. Review the producibility of the design to ensure that it can be produced with the available technology

Explanation:

1. The appraisal of the design includes the consideration of the factors of the design and the building of reliability and efficiency into the design from the beginning

2. Ascertain if the product will require toughness, elasticity, and if will be subject to sudden or repeated loading conditions

3. Ensure that the design can be readily produced with the accessible manufacturing equipment during the conceptualization stage of the design.

4 0
3 years ago
When a variable is stored in memory, it is associated with an address. To obtain the address of a variable, the & operator c
liubo4ka [24]

Answer:

Explanation:

1) C program file addressOfScalar.c

#include <stdio.h>

int main()

{

//intialize a char variable, print its address and the next address

char charvar = 'a';

printf("address of charvar = %p\n", (void *)(&charvar));

printf("address of charvar - 1 = %p\n", (void *)(&charvar - 1));

printf("address of charvar + 1 = %p\n", (void *)(&charvar + 1));

//intialize a int variable, print its address and the next address

int intvar = 1;

printf("address of intvar = %p\n", (void *)(&intvar));

printf("address of intvar - 1 = %p\n", (void *)(&intvar - 1));

printf("address of intvar + 1 = %p\n", (void *)(&intvar + 1));

}

In C programming language, an int variable takes 4 bytes of memory. So any arithmetic on integer address, always considers it as 4 bytes of data. So intvar-1 refers to a location 4 bytes before intvar's address and intvar+1 refers to 4 bytes after intvar's address.

3 0
3 years ago
Compute the number of games using the formula of “SINGLE ROUND ROBIN” and plot the games in a table:
Bogdan [553]

Answer:

N=27.02

Explanation:

3 0
2 years ago
Other questions:
  • A distillation column is initially designed to separate a mixture of toluene and xylene at around ambient temperature (say, 100°
    13·1 answer
  • A rigid tank contains an ideal gas at 40°C that is being stirred by a paddle wheel. The paddle wheel does 240 kJ of work on the
    9·1 answer
  • An experimentalist claims that, based on his measurements, a heat engine receives 300 Btu of heat from a source of 900 R, conver
    14·1 answer
  • At the grocery store you place a pumpkin with a mass of 12.5 lb on the produce spring scale. The spring in the scale operates su
    5·1 answer
  • A highway reconstruction project is being undertaken to reduce crash rates. The reconstruction involves a major realignment of t
    14·1 answer
  • 15 POINTS! Help.
    9·2 answers
  • To revise a monthly budget, changes in which categories might need to be addressed? Check all that apply.
    13·1 answer
  • If Ori gives a friend three reasons for preferring soccer to basketball, that is an algorithm.
    14·2 answers
  • PLEASE HELP AND ANSWER MY OTHER QUESTIONS!,
    7·1 answer
  • Select the correct answer.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!