+ 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))
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))
+ 2
Thanks,it really helped👍👍👍