+ 1

What is the problem in my code for solving Average of rows in data science course

from numpy import * c=[] n,p=[int(x) for x in input().split()] for j in range(n): k=input().split() c=c+k for t in range(len(c)): c[t]=float(c[t]) c=array(c) c=c.reshape(n,p) a=[] for i in range(n): a.append((1/p)*sum(c[i,:])) print(array(a))

24th Feb 2021, 4:05 AM
Shivaye Modi
Shivaye Modi - avatar
2 ответов
+ 3
Based on the problem, you have to round each average to 2 decimals. You can use the array method 'round'. print(array(a).round(2))
24th Feb 2021, 4:21 AM
noteve
noteve - avatar
+ 2
Thanks,it really helped👍👍👍
24th Feb 2021, 4:29 AM
Shivaye Modi
Shivaye Modi - avatar