+ 27
[SOLVED](by master)[code error] Help me find the mistake??
In a matrix, or 2-d array X, the averages (or means) of the elements of rows is called row means. Task Given a 2D array, return the rowmeans. Input Format First line: two integers separated by spaces, the first indicates the rows of matrix X (n) and the second indicates the columns of X (p) Next n lines: values of the row in X Output Format An numpy 1d array of values rounded to the second decimal. 2 2 1.5 1 2 2.9 Sample Output [1.25 2.45] https://code.sololearn.com/c6EK5toPx4YV
26 Respuestas
+ 12
Sω(ᗒ✧ᕙ☞Aᕗ✧ᗕ)ti
Use mean function instead of self calculated average.
import numpy as q
n, p = [int(x) for x in input().split()]
a = []
while n > 0:
#s = sum([float(x) for x in input().split()])
s = q.array(input().split(), dtype = float)
mean = s.mean()
a.append(round(mean, 2))
n -= 1
print(q.array(a))
+ 9
A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟ thx master it's solved
I still don't understand it totally 🤣
Soi I will study more of your code!!
Thanks anyway 😊
+ 9
mycrochip thank u so much your code run purely good
Thank u for giving it so much time
I appreciate it more than anyone else in today😀
+ 9
mycrochip that's too much brother I can't take it .🤣🤣🤣
I thanked u earlier cause u won't feel bad As we all r living beings so we can give a little mental happiness to everybody
#no_more_than_that😅
+ 9
mycrochip lots of laate n mukke
If u continue
Lol!!!
+ 7
mycrochip brother ☹️ thanks for try but!!
1) output should be an array
2)your code is very complex ....a little bit hard for me to read
3) your code generate 5_test_error🥺
+ 5
I'm on it
+ 4
I hope you find this useful.
https://code.sololearn.com/c2Q9Aiw5H8Io/?ref=app
+ 4
Hmm ..
+ 4
Click the link again. I have converted my result to an array.
If it works, I'll explain further.
Test it for now
+ 4
Ok. Good.
You're welcome.
Anyways, the below will receive any number of rows and columns:
https://code.sololearn.com/cYvU5H4AUuq3/?ref=app
+ 4
😊
You're welcome. I learned a lot too
+ 4
Caleb Guerra Ortega Molina Sánchez
So learn python and Know NumPy. Btw how did you know "NumPy" if you don't know?
+ 3
Firstly, you are required to receive three row inputs
1.) n_rows, n_cols --> np.shape()
2.) row_1: [00 01] --> row_0, col_0; row_0, col_1
3.) row_2: [ 10 11 ] --> row_1, col_0; row_1, col_1
+ 3
Do you have some of the sample test...
+ 3
Oh. I see. I will loop through the number of rows
+ 3
I will walk you through all the steps block by block when you're free.
+ 3
Sω(ᗒ✧ᕙ☞Aᕗ✧ᗕ)ti
Then mukka laat 😁😁😁
+ 3
Sω(ᗒ✧ᕙ☞Aᕗ✧ᗕ)ti mycrochip
I don't know numpy
+ 3
A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟ I look the word very much times😅😅😅😅