write a program that stores n elements of anarray of integers, then finds:
i) the average,
ii) the standard deviation,
iii) the position & value of themaximum element in the array.

Respuesta :

Answer:

The following code is in python:

import statistics as st

n=int(input("Enter the number of elements \n"))#taking input of the number n..

arrayint=list(map(int,input("Enter the n elements : \n").strip().split()))[:n]#taking input of the array..

print("The mean is "+ str(st.mean(arrayint)))#printing the mean..

print("The standard deviation is "+str(st.stdev(arrayint)))#printing the standard deviation..

max=-1000000

pos=-1

for i in range(len(arrayint)):#loop for finding the maximum and position

   if arrayint[i]>max:

       pos=i

       max=arrayint[i]

print("The maximium and position are "+str(max)+" and "+str(pos))#printing the maximum and the position..

Output:-

Enter the number of elements

5

Enter the n elements :

5 20 12 45 10

The mean is 18.4

The standard deviation is 15.820872289478858

The maximium and position are 45 and 3

Explanation:

I have used statistics module in python to calculate the mean and standard deviation.I have looped over the list to find the maximum and it's position in the array.

ACCESS MORE