0

Data Science With Python Class..Need Help on Project

I am doing the 'Average of Rows' Project (the first project in the Data Science with Python class). Here is my code. It only works for the first 3 test cases but not the others, which are locked. I don't know why it isn't working. Any help? Thanks in advance: import numpy as np n, p = [int(x) for x in input().split()] mat=[] for i in range(n): mat.append([]) mat[i]=[float(x) for x in input().split()] mat_arr=np.array(mat) print(mat_arr.mean(axis=1))

20th Jan 2021, 6:42 AM
Alec Brown
2 ответов
+ 2
Based on the problem, you have to round the mean into 2 decimal places. print(mat_arr.mean(axis=1).round(2)) Just an Additional: You can just append the list comprehension right away to mat, because list comprehension is already generating a list, rather than appending an empty list then changing it. Here's the code, if you have more questions, please feel free to ask. Thanks! https://code.sololearn.com/cA7a11a14A23
20th Jan 2021, 7:08 AM
noteve
noteve - avatar
0
https://code.sololearn.com/c4A21a20A24a/?ref=app see this
20th Jan 2021, 7:41 AM
Rahima Mirzad
Rahima Mirzad - avatar