Problem:


Standard Deviation

  You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn.

The variance &alpha;2 is defined by  

&alpha;2  = (&sum;ni=1(si - m)2)/n

  where m is an average of si.

  The standard deviation of the scores is the square root of their variance.
  

Input

  The input consists of multiple datasets. Each dataset is given in the following format:

n
s1 s2 ... sn

  The input ends with single zero for n.

Output

  For each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4.

Constraints

n ≤ 1000

0 ≤ si ≤ 100 

Sample Input

5
70 80 100 90 20
3
80 80 80
0

Sample Output

27.85677655
0.00000000



Sample input:
5
70 80 100 90 20
3
80 80 80
0


Sample output:
27.85677655
0.00000000

Submission status: Runtime Error

Solution code:
from math import sqrt

while True:
    n=int(input())
    
    if n==0:
        break
    else:
        score=[float(i) for i in input().split()]
        avg=sum(score)/len(score)
        tmp=[(avg-score(i))**2 for i in range(n)]
        ans=math.sqrt(sum(tmp)/n)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
import sys
import collections
import numpy
import unittest


def calculate_standard_deviation():
    lines = sys.stdin.readlines()
    data = []
    i = 0
    while(i < len(lines)):
        if(int(lines[i].rstrip()) == 0) :
            break
        else:
            data.append([ int(score) for score in lines[i+1].rstrip().split() ])
            i += 2

    for scores in data:
        print(numpy.std(scores))

def __input_error():
    print("input error")
    return -1

class __TestValueClass(unittest.TestCase):
    def testEqual(self,func,tuples):
        self.testFunction(self.assertEqual,func,tuples)
    
    def testFunction(self,assertfunc,func,tuples):
        #tuples[index] = ([*arguments of func], compared value)
        for item in tuples:
            try:
                if isinstance(item[0], collections.Iterable):
                    assertfunc(func(*item[0]),item[1])
                else:
                    assertfunc(func(item[0]),item[1])
            except Exception as msg:
                swidth = 15
                print("="*50)
                print("-- Assertion Error in '" + func.__name__ + "' --")
                print("arguments".ljust(swidth)+":",item[0])
                print("compared value".ljust(swidth)+":",item[1])
                print("message".ljust(swidth)+":")
                print(msg)
                sys.exit()
        print(func.__name__,": succeeded")
        
#test
if __name__ == "__main__" :

    calculate_standard_deviation()
#    test = __TestValueClass()

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
import sys
import numpy

def calculate_standard_deviation():
    lines = sys.stdin.readlines()
    data = []
    i = 0
    while(i < len(lines)):
        if(int(lines[i].rstrip()) == 0) :
            break
        else:
            data.append([ int(score) for score in lines[i+1].rstrip().split() ])
            i += 2

    for scores in data:
        print(numpy.std(scores))
        
#test
if __name__ == "__main__" :

    calculate_standard_deviation()

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
import sys
import collections
import numpy
import statistics
import unittest


def calculate_standard_deviation():
    lines = sys.stdin.readlines()
    data = []
    i = 0
    while(i < len(lines)):
        if(int(lines[i].rstrip()) == 0) :
            break
        else:
            data.append([ int(score) for score in lines[i+1].rstrip().split() ])
            i += 2

    for scores in data:
        print(statistics.pstdev(scores))

def __input_error():
    print("input error")
    return -1

class __TestValueClass(unittest.TestCase):
    def testEqual(self,func,tuples):
        self.testFunction(self.assertEqual,func,tuples)
    
    def testFunction(self,assertfunc,func,tuples):
        #tuples[index] = ([*arguments of func], compared value)
        for item in tuples:
            try:
                if isinstance(item[0], collections.Iterable):
                    assertfunc(func(*item[0]),item[1])
                else:
                    assertfunc(func(item[0]),item[1])
            except Exception as msg:
                swidth = 15
                print("="*50)
                print("-- Assertion Error in '" + func.__name__ + "' --")
                print("arguments".ljust(swidth)+":",item[0])
                print("compared value".ljust(swidth)+":",item[1])
                print("message".ljust(swidth)+":")
                print(msg)
                sys.exit()
        print(func.__name__,": succeeded")
        
#test
if __name__ == "__main__" :

    calculate_standard_deviation()
#    test = __TestValueClass()

Submission status: Runtime Error

Solution code:
import math
while True:
    n = int(input())
    score = [ int(i) for i in input().split(" ") ] 
    average = sum(score) / n
    if n == 0:
        break
    a2 = 0
    for s in score:
        a2 += (s - average) ** 2

    print("{:.8f}".format(math.sqrt(a2) / n ) )

Submission status: Runtime Error

Solution code:
import math
while True:
    n = int(input())
    score = [ int(i) for i in input().split(" ") ] 
    average = sum(score) / n
    if n == 0:
        break
    a2 = 0
    for s in score:
        a2 += (s - average) ** 2

    print("{:.8f}".format(math.sqrt(a2) / n ), end ="\n")

Submission status: Runtime Error

Solution code:
import math
while True:
    n = int(input())
    score = [ int(i) for i in input().split(" ") ] 
    average = sum(score) / n
    if n == 0:
        break
    else:
        a2 = 0
        for s in score:
            a2 += (s - average) ** 2

        print("{:.8f}".format(math.sqrt(a2) / n ), end ="\n")

Submission status: Runtime Error

Solution code:
import math
while True:
    n = int(input())
    score = [ int(i) for i in input().split(" ") ] 
    average = sum(score) / n
    if n == 0:
        break
    a2 = 0
    for s in score:
        a2 += (s - average) ** 2
    print("{:.8f}".format(math.sqrt(a2) / n , end ="\n")

Submission status: Runtime Error

Solution code:
import math
while True:
    n = int(input())
    score = [ int(i) for i in input().split(" ") ] 
    average = sum(score) / float(n)
    if n == 0:
        break
    a2 = 0
    for s in score:
        a2 += (s - average) ** 2
    print("{:.8f}".format(math.sqrt(a2) / n )

Submission status: Runtime Error

Solution code:
import math
while True:
    n = int(input())
    score = [ int(i) for i in input().split(" ") ] 
    average = sum(score) / float(n)
    if n == 0:
        break
    a2 = 0
    for s in score:
        a2 += (s - average) ** 2
    print("{0:.8f}".format(math.sqrt(a2) / n )

Submission status: Runtime Error

Solution code:
import math
while True:
    n = int(input())
    score = [ int(i) for i in input().split(" ") ] 
    average = sum(score) / float(n)
    if n == 0:
        break
    print("{0:.8f}".format(math.sqrt(sum([(x-average) ** 2]) / 2 )

Submission status: Runtime Error

Solution code:
import math
while True:
    n = int(input())
    score = [ int(i) for i in input().split(" ") ] 
    average = sum(score) / float(n)
    if n == 0:
        break
    print("{:.8f}".format(math.sqrt(sum([(x-average) ** 2]) / n )

Submission status: Runtime Error

Solution code:
import math
while True:
    n = int(input())
    score = [ int(i) for i in input().split(" ") ] 
    average = sum(score) / float(n)
    if n == 0:
        break
    print("{:.8f}".format(math.sqrt(sum([(x-average) ** 2]) / float(n) )

Submission status: Runtime Error

Solution code:
import math
while True:
    n = int(input())
    score = [ int(i) for i in input().split(" ") ] 
    average = sum(score) / float(n)
    if n == 0:
        break
print("{:.8f}".format(math.sqrt(sum([(x-average) ** 2]) / float(n) )

Submission status: Runtime Error

Solution code:
import math
while True:
    n = int(input())
    score = [ int(i) for i in input().split(" ") ] 
    average = sum(score) / n
    if n == 0:
        break
    print("{:.8f}".format(math.sqrt(sum([(x-average) ** 2]) / n )

Submission status: Runtime Error

Solution code:
import math
while True:
    n = int(input())
    if n == 0:
        break
    score = [ int(i) for i in input().split(" ") ] 
    average = sum(score) / n
    print("{:.8f}".format(math.sqrt(sum([(x-average) ** 2]) / n )

Submission status: Runtime Error

Solution code:
import math
while True:
    n = int(input())
    if n == 0:
        break
    score = [int(i) for i in input().split(" ")]
    average = sum(score) / n
    print("{:.8f}".format(math.sqrt(sum([(x-average) ** 2]) / n )

Submission status: Runtime Error

Solution code:
import math
while True:
    n = int(input())
    if n == 0:
        break
    s = [int(i) for i in input().split(" ")]
    m = sum(s) / n
    print("{:.8f}".format(math.sqrt(sum([(x-m) ** 2]) / n )

Submission status: Runtime Error

Solution code:
import math
while True:
    n = int(input())
    if n == 0:
        break
    s = [int(i) for i in input().split(" ")]
    m = sum(s) / n
    print("{:.8f}".format(math.sqrt(sum([(x-m) ** 2]) / n)

Submission status: Runtime Error

Solution code:
import math
while True:
    n = int(input())
    if n == 0:
        break
    s = [int(i) for i in input().split(" ")]
    m = sum(s) / n
    print("{:.8f}".format(math.sqrt(sum([(x-m) ** 2 for x in s]) / n)

Submission status: Runtime Error

Solution code:
import math

def hensa(n, S):
 m = sum(S)/n
 x = 0
 for i in S:
  x += (i - m) ** 2
 hensa = math.sqrt(x / n)
 return hensa

n = 1
while n != 0:
 n = int(input())
 S = list(map(int, input().split()))
 print("{0:04f}".format(hensa(n, S)))

Submission status: Runtime Error

Solution code:
n = int(input())
d = list(map(int,input().split()))
import math
m = sum(d) / n
print(math.sqrt( (x-m)**2/n for x in d))

Submission status: Runtime Error

Solution code:
import statistics
while True:
    x = input()
    if x == 0:
        break
    else:
        ls = list(map(int, input().split()))
        print(statistics.pstdev(ls))

Submission status: Runtime Error

Solution code:
import statistics
while True:
    x = input()
    if x == 0:
        break
    else:
        ls = list(map(int, input().split()))
        print("{0:.8f}".format(statistics.pstdev(ls)))

Submission status: Runtime Error

Solution code:
import statistics

while True:
  s=int(input())
  if s==0:
    break
  else:
   lst=list(map(int,input().split()))
  print("{0.8}".format(statitics.pstdev(lst)))

Submission status: Runtime Error

Solution code:
import statistics

while True:
  s=int(input())
  if s==0:
    break
  else:
   lst=list(map(int,input().split()))
  print("{0:.8}".format(statitics.pstdev(lst)))

Submission status: Runtime Error

Solution code:
from statistics import pstdev

while True:
    if input() == 0: break
    v_list = (int(x) for x in input().split())
    print(pstdev(v_list))

Submission status: Runtime Error

Solution code:
import numpy as np
while True:
    num = int(input())
    if num == 0: break
    array = np.array(list(map(float, input().split())))
    print(np.std(array))

Submission status: Runtime Error

Solution code:
import numpy as np
while True:
    num = int(input())
    if num == 0: break
    array = np.array(list(map(float, input().split())))
    print(str(np.std(array)))

Submission status: Runtime Error

Solution code:
import bumpy as np
while True:
    n= int(input())
   if n == 0:
        break
    a=map(int, input().split())
    print(np.std(a)

Submission status: Runtime Error

Solution code:
import numpy as np
while True:
    n= int(input())
   if n == 0:
        break
    a=map(int, input().split())
    print(np.std(a)

Submission status: Runtime Error

Solution code:
import numpy as np
while True:
    n= int(input())
   if n == 0:
        break
    a=map(int, input().split())
    print(np.std(a))

Submission status: Runtime Error

Solution code:
import numpy as np
while True:
    n= int(input())
    if n == 0:
        break
    a=map(int, input().split())
    print(np.std(a))

Submission status: Runtime Error

Solution code:
import numpy as np
while True:
    n= int(input())
    if n == 0:
        break
    print(np.std(list(map(int, input().split()))))

Submission status: Runtime Error

Solution code:
import numpy as np
while True:
    n= int(input())
    if n == 0:
        break
    print(np.std(list(map(int, input().split())), dtype=np.float64))

Submission status: Runtime Error

Solution code:
import numpy as np
import math
while True:
    n= int(input())
    if n == 0:
        break
    a=list(map(int,input().split()))
    m=np.mean(a)
    s=0
    for i in a:
        s+=(i-m)**2
    s/=n
    print(math.sqrt(s))

Submission status: Runtime Error

Solution code:
import numpy as np
import math
while True:
    n= int(input())
    if n == 0:
        break
    a=list(map(int,input().split()))
    m=np.mean(a)
    s=0
    for i in a:
        s+=(i-m)**2
    s/=n
    print("{0:.8f}".format(math.sqrt(s)))

Submission status: Runtime Error

Solution code:
import numpy as np
import math
while True:
    n= int(input())
    if n == 0:
        quit()
    a=list(map(int,input().split()))
    m=np.mean(a)
    s=0
    for i in a:
        s+=(i-m)**2
    s/=n
    print("{0:.8f}".format(math.sqrt(s)))

Submission status: Runtime Error

Solution code:
import numpy as np
import math
while True:
    n= int(input())
    if n == 0:
        break
    a=list(map(float,input().split()))
    m=np.mean(a)
    s=0
    for i in a:
        s+=(i-m)**2
    s/=n
    print("{0:.8f}".format(math.sqrt(s)))

Submission status: Runtime Error

Solution code:
import numpy as np
import math
while True:
    n= int(input())
    if n == 0:
        break
    a=list(map(float,input().split())
    m=np.mean(a)
    s=0
    for i in a:
        s+=(i-m)**2
    s/=n
    print("{0:.8f}".format(math.sqrt(s)))

Submission status: Runtime Error

Solution code:
import numpy as np
while input()!='0':
    print('%.8f'%(np.std(np.array(list(map(float,input().split()))))))

Submission status: Runtime Error

Solution code:
import numpy as np
while True:
    n = int(input())
    if n == 0:
        break

    s = list(map(int, input().split()))
    for i in range(n):
        std = np.std(s)
    print("{0:.8f}".format(std))

Submission status: Runtime Error

Solution code:
import numpy as np
while True:
    n = int(input())
    if n == 0:
        break

    s = list(map(int, input().split()))
    for i in range(n):
        std = np.std(s)
    print("{0:.8f}".format(std), end="\n")

Submission status: Runtime Error

Solution code:
import numpy as np
while True:
    n = int(input())
    if n == 0:
        break

    s = list(map(int, input().split()))
    for i in range(n):
        std = np.std(s)
    print("{0:.8f}".format(std))

Submission status: Runtime Error

Solution code:
from statistics import pstdev
while True:
    data_count = int(input())
    if data_count == 0:
        break
    print(pstdev(sum(int(x) for x in input().split())))

Submission status: Runtime Error

Solution code:
n = int(input())
data = input().split()
import math
sum = 0
for i in range(n):
    sum = sum + int(data[I])
average = sum / n
a = 0
for i in range(n):
    a = a + (int(data[i]) - average)**2
print('{}'.format(math.sqrt(a/n)))

Submission status: Runtime Error

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    data = input().split()
    import math
    sum = 0
    for i in range(n):
    sum = sum + int(data[i])
    average = sum / n
    a = 0
    for i in range(n):
    a = a + (int(data[i]) - average)**2
    print('{}'.format(math.sqrt(a/n)))

Submission status: Runtime Error

Solution code:
while input():
 s=list(map(int,input().split()))
 n=len(s)
 a=sum(s)/n
 print((sum([x*x for x in s])/n-a*a)**.5)

Submission status: Runtime Error

Solution code:
while input()>0:
 s=list(map(int,input().split()))
 n=len(s)
 a=sum(s)/n
 print((sum([x*x for x in s])/n-a*a)**.5)

Submission status: Runtime Error

Solution code:
import numpy as np
while True:
    num = int(input())
    if num == 0:
        break
    data = np.array(list(map(int, input().split())))
    print(np.std(data))

Submission status: Runtime Error

Solution code:
import math
while(True):
    if input() == '0':
        break
    a = map(int, input().split())
    m = sum(a) / len(a)
    b = 0
    for i in a:
        b += (i - m) ** 2.0
    stddev = math.sqrt(b / n)
    print(stddev)

Submission status: Runtime Error

Solution code:
import math
while(True):
    if input() == '0':
        break
    a = list(map(int, input().split()))
    m = sum(a) / len(a)
    b = 0
    for i in a:
        b += (i - m) ** 2.0
    stddev = math.sqrt(b / n)
    print(stddev)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

from statistics import stdev

while True:
    n = int(input())

    if n == 0:
        break

    s = list(map(int, input().split()))
    print(stdev(s))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

import math

while True:
    n = int(input())

    if n == 0:
        break

    s = list(map(float, input().split()))
    mean = sum(s) / len(s)

    for i in range(len(s)):
        s[i] = (s[i] - sum) * (s[i] - sum)

    variance = sum(s) / len(s)
    stdev = math.sqrt(variance)

    print(stdev)

Submission status: Runtime Error

Solution code:
import numpy as np
while 1:
    N = int(input())
    if N == 0:
        break
    xs = np.array(list(map(int, input().split())))
    
    print(np.sqrt(np.var(xs)))

Submission status: Runtime Error

Solution code:
import numpy as np

while 1:
    N = int(input())
    if N == 0:
        break
    xs = np.array(list(map(int, input().split())))
    print(xs)
    print(np.sqrt(np.var(xs)))

Submission status: Runtime Error

Solution code:
while 1:
    N = int(input())
    if N == 0:
        break
   print(0)

Submission status: Runtime Error

Solution code:
import statistics as st

while True:
    n = float(input())
    if n == 0:
        break
    scores = list(map(float, input().split()))
    std = st.stdev(scores)
    print(std)

Submission status: Runtime Error

Solution code:
# AOJ ITP1_10_C

import math

def intinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    while True:
        n = int(input())
        if n == 0: break
        data = intinput()
        sum_1 = 0  # 1乗の総和
        sum_2 = 0  # 2乗の総和
        for i in range(n):
            sum_1 += data[i]; sum_2 += data[i] ** 2
        sigma = math.sqrt((sum_2 - (sum_1 ** 2)) / n)
        print(sigma)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
while True:
    n = int(raw_input())
    if n == 0: break

    for i in range(n):
        x = map(int, raw_input().split())
        ave = sum(x) / n
    std = (sum([(e-ave)**2 for e in x])/n)**0.5
    print std

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
import io
import re
import math

while True:
#    i = 0
    n = int(raw_input())
    l = map(float, raw_input().split())
    if n==0: break
# hyojunhensa**2 = sum(tokuten-heikinten)**2)/ninzu
    avg=sum(l)/len(l)
    print avg
    naka=0
    for i in l:
        print naka
        naka+=(i-avg)**2
    hyo2 = naka/n
    print (hyo2)**0.5

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
import io
import re
import math

while True:
    n = int(raw_input())
    l = map(float, raw_input().split())
    if n==0:
    break
# hyojunhensa**2 = sum(tokuten-heikinten)**2)/ninzu
    avg=sum(l)/len(l)
    print avg
    naka=0
    for i in l:
        print naka
        naka+=(i-avg)**2
    hyo2 = naka/n
    print (hyo2)**0.5

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
import io
import re
import math

while True:
#    i = 0
    n = int(raw_input())
    l = map(float, raw_input().split())
    if n==0: break
# hyojunhensa**2 = sum(tokuten-heikinten)**2)/ninzu
    avg=sum(l)/len(l)
    naka=0
    for i in l:
        naka+=(i-avg)**2
    hyo2 = naka/n
    print (hyo2)**0.5