• + 0 comments

    I get 2.98, but the answer is wrong.

    Althoug std of [1.0, 2.0, 3.0, 2.98] is the same as std of [1,2,3], which is 0.82 (rounded to 2 decimal places, as decribed)

    What am I missing?

    import numpy as np
    
    arr = [1.0, 2.0, 3.0]
    
    std = round(np.std(arr),2)
    
    print('Standard Deviation of ', arr, 'is', std)
    print()
    
    num = 0.0
    for i in range(1,100001):
      num = round(num + 0.01, 2)
      arr.append(num)
      res_std = round(np.std(arr), 2)
      if res_std == std:
        res = num
      arr.pop()
    print(res)