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
MrRissso [65]
2 years ago
7

write a program, using python, to determine the mean, median, and standard deviation of a list of numbers. In addition, count th

e number of duplicate numbers in the code and list any numbers that occur more than once, with the number of times the number occurs. submit a listing of your code, and the results. List = [3, 6, 7, 2, 8, 9, 2, 3, 7, 4, 5, 9, 2, 1, 6, 9, 6]
Computers and Technology
1 answer:
Mekhanik [1.2K]2 years ago
7 0

Answer:

The program to this question can be given as:

Program:

import math   #import packages

import sys

number =  [3, 6, 7, 2, 8, 9, 2, 3, 7, 4, 5, 9, 2, 1, 6, 9, 6]  #define list  

n = len(number)   # taking length of list

print("Sample Data: ",number)  #print list

#find Mean

print("Mean is: ")  #message  

add = sum(number)  # addition of numbers.

mean = add / n  #add divide by total list number.

print(str(mean))  #print mean

number.sort()   #short list by using sort function

#find Median

print("Median is: ")

if n % 2 == 0:        #conditional statement.

   median1 = number[n//2]  

   median2 = number[n//2 - 1]  

   median = (median1 + median2)/2

else:  

   median = number[n//2]  

print(str(median)) #print median

#find Standard deviation.

print("Standard Deviation :")

def SD(number):  #define function SD

   if n <= 1:      #check condition

       return 0.0   #return value.

   mean,SD = average(number), 0.0  

   # find Standard deviation(SD).

   for j in number:

       SD =SD+(float(j)-mean)**2

       #calculate Standard deviation holing in variable SD  

       SD =math.sqrt((SD)/float(n-1))#using math sqrt function.

   return SD  #return value.

def average(av):         #define function average

   n,mean =len(av), 0.0  

   if n <= 1:

       return av[0]   #return value.

   # calculate average

   for I in av:

       mean +=float(i)

       mean /= float(n)

   return mean             #return value.

print(SD(number)) #print value

Output:

Sample Data:  [3, 6, 7, 2, 8, 9, 2, 3, 7, 4, 5, 9, 2, 1, 6, 9, 6]

Mean is:  

5.235294117647059

Median is:  

6

Standard Deviation :

2.140859045465338

Explanation:

In the above python program first, we import packages to perform maths and other functions. Then we declare the list that is number in the list the elements are given in the question. Then we declare variable n in this variable we take the number of elements present in the list and print the list first. In the list, we perform three operations that can be given as:

Mean:  

In the mean operation firstly we define the variable add in this variable we add all elements of the list by using the math sum function then we divide the number by number of elements present in the list. and sore the value in the mean variable and print it.

Median:

In the median section firstly we sort the list by using the sort function. Then we use the conditional statements for calculating median. In the if block first we modules the number by 2 if it gives 0. it calculates first and second median the add-in median .else it will print that number.

Standard Deviation:

In the standard deviation part first, we define two functions that is SD() function and average().In the SD() function we pass the list as the parameter. In this function we use the conditional statement in the if block we call the average() function and use for loop for return all values. In the average() function we calculate the average of the all number and return value. At last, we print all values.

You might be interested in
What is meant by backing up files through cloud computing?
myrzilka [38]
Cloud backup<span> solutions enable enterprises or individuals to store their data and computer </span>files<span> on the Internet </span>using<span> a storage service provider, rather than storing the data locally on a physical disk, such as a hard drive or tape </span>backup<span>.</span>
4 0
3 years ago
Read 2 more answers
Write a function addOne that adds 1 to its integer referenceparameter. The function returns nothing.
Alekssandra [29.7K]

Answer:

void addOnefunction(int referenceparameter){

   

   referenceparameter = referenceparameter + 1;

}

Explanation:

The function is the block of the statement which performs the special task.

Syntax:

type name(parameter_1, parameter_2,...){

     statement;

}

first, we define the return type of the function like int which return an integer value, a float which returns decimal value or void which returns nothing.

then, define the parameters in the function which takes the value from the calling function and then we can use that parameter in the statement.

we can define any one of the parameters, there is no restriction for define the parameter.

we create the function addOnefunction which return is void and declare the one parameter referenceparameter, integer type.

then, add the parameter with 1 and store in the same parameter.

For adding, we can use the operator '+'.

like,

 referenceparameter = referenceparameter + 1;

5 0
3 years ago
Maria found a cupcake recipe on a cooking blog. However, she would like to read comments and suggestions before she begins bakin
Mnenie [13.5K]
Maria should use the Cooking blog that has known and verified information and step by step instructions Comments can lead to disaster and/or incorrect recipe use
8 0
3 years ago
Read 2 more answers
Home communication involves controlling systems such as heating, cooling, and security.
katen-ka-za [31]

Answer:

<em>A. True</em>

Explanation:

<em>Home communications involves automating home. It includes controlling the air-con,water heater, webcam, etc. A</em>

6 0
3 years ago
Which is an effect of short-term environmental changes?
allochka39001 [22]
Adaptation or death






.
4 0
2 years ago
Other questions:
  • An ______ is a simplified image. [4 letters]​
    7·2 answers
  • In this assignment, you are going to add conditional formatting to the spreadsheet you used in the previous
    13·1 answer
  • What's the best option if you can't show your PowerPoint presentation at all? A. Create PDF/XPS Document B. Prepare a Package Pr
    11·2 answers
  • How do solar cells translate heat energy into mechanical energy
    13·1 answer
  • What does zooming do? A. Changes your view of the Frame Editor to be closer or farther away B. Changes your view of the Event Ed
    12·1 answer
  • A number of related records that are treated as a unit is called
    6·1 answer
  • What percentage of people with internet access use emojis?
    11·1 answer
  • What can cause a Lenovo computer to be very slow right after after turning it on?
    14·1 answer
  • PLEASE HURRY I WILL GIVE BRAILIEST TO WHO EVER ANSWERS AND IS CORRECT
    14·2 answers
  • Write a nested loop to set values as follows: [0] [1] [2] [3] [4] [0] 1 2 3 4 5 [1] 1 2 3 4 5 [2] 1 2 3 4 5 [3] 1 2 3 4 5
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!