0

Average of rows end of module project from data science course

from the test cases 4 out of 5 are correct. But can't make the last one correct. I suspect the problem is with the round function. Can anyone help me with my code? https://code.sololearn.com/calpruBFk5FV/?ref=app

15th Feb 2021, 4:58 PM
Mir Abir Hossain
Mir Abir Hossain - avatar
4 Respostas
+ 1
I think that is because rounding in NumPy is different from rounding in Python. So use numpy.round() method instead of Python round function: Append first each rows to 'b' (not rounded) then use numpy round method at last line to round off each value. _______________________ import numpy as np n, p = [int(x) for x in input().split()] b = np.array([]) for i in range(n): a = list(float(i) for i in input().split()) b = np.append(b,sum(a)/len(a)) print(b.round(2)) ________________________
15th Feb 2021, 5:11 PM
noteve
noteve - avatar
+ 1
n, p = [int(x) for x in input().split()] list = [] for i in range(n): list.append([float(j) for j in input().split()]) import numpy as np arr = np.array(list, dtype='f') mean = arr.mean(axis=1) print(mean.round(2))
14th Sep 2021, 7:48 AM
Brigido bergado jr
Brigido bergado jr - avatar
+ 1
Copy this code and like and check
14th Sep 2021, 7:49 AM
Brigido bergado jr
Brigido bergado jr - avatar
0
Thanks a lot Cyan . It worked ❤️
15th Feb 2021, 5:42 PM
Mir Abir Hossain
Mir Abir Hossain - avatar