import numpy as np
from scipy import stats
import statistics
def stats_values(arr):
#Input : arr - Numpy array
#Output: Function must print the statistics of the array in the following order
#1. Mean
#2. Median
#3. Standard Deviation
#4. Variance
#5. Mode
#5. Inter-Quartile Range
#Note: All the answers must be of Float datatype.Round your answers to 2 digits.
#'''
#Write your code here
x1 = np.mean(arr)
print('%.1f'%x1)
x2 = np.median(arr)
print('%.1f'%x2)
x3 = np.std(arr, dtype = np.float32)
print('%.2f'%x3)
x5 = np.var(arr)
print('%.1f'%x5)
MODE = stats.mode(arr)
x4= MODE[0]
print('%.1f'%x4 )
Q1 = np.percentile(arr, 25, interpolation = 'midpoint')
Q3 = np.percentile(arr, 75, interpolation = 'midpoint')
IQR = Q3 - Q1
print('%.1f'%iqr )
if __]name__ == "__main__":
array_num=[]
n=int(input())
for i in range(n):
a=input()
af=float(a)
array_num.append(af)
arr=np.array(array_num)
stats_values(arr)
#-------------------------------------------------------------------------------------------
#This is my code but it's not passing other other cases except one.below are arr[] values
#**Test case 0:** [2. 2. 3. 5.] --working
#**Test case 1:** [ 9.2 10.7 6.8 9. 3.4 5.7 5.7]
#**Test case 2:** [23. 34. 56. 2.3 4.5 4.5 67. 89. 89. 89. 89. 89.
#4.67 3.45 2.45 3.45 6.8 9. 2.45 56.6 ]
#**Test case 3:**** [23. 34. 56. 2.3 4.5 4.5 67. 89. 89. 89. 89. 89.
#4.67 3.45 2.45 3.45 6.8 9. 2.45 56.6 45. 45. 45. 45.
#45. 45. 56. 78. 89. 78. 90. 12. 34. 56. 78. 23.
#45. 67. 89. 89. ]
question from:
https://stackoverflow.com/questions/66059924/python3below-is-pre-defined-stats-valuearrkindly-help-me-with-the-solution 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…