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]
3 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]3 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 created for each user the first time the user logs onto windows?
Naddik [55]
<span>A profile is made the first occasion when that a client sign on to a Windows XP, Windows 2000, or Windows NT® Workstation–based PC. A client profile is a gathering of settings and documents that characterizes the condition that the framework loads when a client sign on. It incorporates all the client arrangement settings, for example, program things, screen hues, organize associations, printer associations, mouse settings, and window size and position. Profiles are not client arrangements and the client has a profile regardless of the possibility that you don't utilize Group Policy.</span>
4 0
3 years ago
Given two ArrayLists of sorted strings (alphabetically ascending), write down a method to merge these sorted strings’ ArrayLists
Elena-2011 [213]

Answer:

see explaination

Explanation:

import java.util.ArrayList;

import java.util.Arrays;

public class Merge {

public static ArrayList<String> mergeList(ArrayList<String> lst1, ArrayList<String> lst2) {

ArrayList<String> result = new ArrayList<String>();

int i = 0, j = 0;

while (i < lst1.size() || j < lst2.size()) {

if (i < lst1.size() && (j >= lst2.size() || lst1.get(i).compareTo(lst2.get(j)) < 0)) {

result.add(lst1.get(i++));

} else {

result.add(lst2.get(j++));

}

}

return result;

}

public static void main(String[] args) {

ArrayList<String> lst1 = new ArrayList<>(Arrays.asList("Austin", "Dallas", "San Fransisco"));

ArrayList<String> lst2 = new ArrayList<>(Arrays.asList("Boston", "Chicago", "Denver", "Seattle"));

System.out.println(mergeList(lst1, lst2));

}

}

8 0
3 years ago
Write a static generic method PairUtil.minmax that computes the minimum and maximum elements of an array of type T and returns a
Gnesinka [82]

Answer:

Explanation:

The following code is written in Java. It is hard to fully create the code without the rest of the needed code including the T class and the Measurable interface. Regardless the following code can be implemented if you have that code available.

 public static T minmax(ArrayList<T> mylist) {

       T min = new T();

       T max = new T();

       for (int x = 0; x < mylist.size(); x++) {

           if (mylist.get(x) > max) {

               max = mylist.get(x);

           } else if (mylist.get(x) < min) {

               min = mylist.get(x);

           }

       }

       

       return (min, max);

   }

5 0
3 years ago
What are 2 ways to access the vendor credit screen in quickbooks online?
kiruha [24]

Answer:

First by

Clicking

New Button (+) THEN click Vendor THEN click Credit

Secondly

Click Expenses Center then click New Transaction then finally click Vendor Credit

4 0
2 years ago
Windows, Apple’s Mac OS, and Unix/Linux are just some of the most common what?
34kurt
Most common PC operating systems
7 0
3 years ago
Read 2 more answers
Other questions:
  • What method of malware infection installs malware through use of a separate browser window that opens uninvited from a Web page?
    7·2 answers
  • What does "FDDI" stand for in Technology?
    5·2 answers
  • A growing number of large organizations have built internal Web sites that provide opportunities for online social networking am
    7·1 answer
  • Gregory Yob is associated with which of these games?
    7·2 answers
  • What is a traffic controller?what are its functions?
    13·1 answer
  • Which of the following are examples of jobs in the allied health profession? select all that apply.
    8·1 answer
  • I need help fixing this please
    6·2 answers
  • I think you have been doing a great job but you haven’t been signing many people up for our new service feature I want you to se
    8·1 answer
  • Drag each tile to the correct box.
    15·2 answers
  • How do u type please help
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!