• + 0 comments

    I got 2.94 if I run the code in VScode, but I got Runtime error when I submitted it. What was the error?

    import numpy as np
    
    A = [1, 2, 3]
    stdA = np.std(A)
    
    mn = float('inf')
    N = 0
    for i in np.arange(0, 4.01, 0.01):
        B = [1, 2, 3, i]
        stdB = np.std(B)
        if (abs(stdA - stdB) <= mn):
            mn = abs(stdA - stdB)
            N = i
    
    print(N)