20 AnswersNew Answer
My code: n, p = [int(x) for x in input().split()] rm =  # rowmean [rm.append(round(sum([float(i) for i in input().split()])/p, 2)) for j in range(n)] import numpy as np print(np.array(rm)) Outputs: test case #5️⃣ my: [1.95 2.23 2.67 1.62] #5️⃣: [1.95 2.22 2.68 1.62] difference: +0.01 -0.01 Probably the problem is in number rounding ⁉️🤔 my: round(x,2) other: x.round(2) Sorry‼️I can't show in public the code which has passed all 5️⃣ tests‼️☹️
I have used np.around and it worked! https://docs.scipy.org/doc/numpy/reference/generated/numpy.around.html
Mihai Apostol [ ⚓ INACTIVE] So is there any other code-coach challenge that cannot be seen directly but it exist🙄🤔?
"For values exactly halfway between rounded decimal values, NumPy rounds to the nearest even value. Thus 1.5 and 2.5 round to 2.0, -0.5 and 0.5 round to 0.0, etc. ... " Notes from: docs.scipy.org/doc
No idea. I already solved it so you can DM me because its Pro.
Interesting 🤔 but in this code coach that's not going to happen because we are rounding to 2 decimal places not to an int value we don't need that method. Janusz Bujak 🇵🇱 I was on the right track. Problem wasn't the round functionality at all but the way you calculated the mean. Replace your sum()/p logic with nparray.mean() and your code will work even when you used the round(x,2) form.
Janusz Bujak 🇵🇱 You are right. I misunderstood that sorry.
Which challenge you are talking about, guys? Can you send a link?
Kuba Siekierzyński https://www.sololearn.com/coach/111?ref=app Data Science - Average of Rows
Dzięki, Janusz Bujak 🇵🇱 , I couldn't find it on the code coach list... 🤔
Kuba Siekierzyński You must advance in your course and the challenge will be available as a DM from SL.
BEN_10🇮🇳 Besides the 72 CCC accessible from the Learn tab, there are 10 more CCC (Python only) related to Data Science and Machine Learning courses which will be available as DM from SL as you advance through the mentioned courses.
Erik Gordon-Quaicoe Amir Mehrabi Jorshari import numpy as np n, p = [int(x) for x in input().split()] m =  [m.append([float(i) for i in input().split()]) for j in range(n)] print(np.mean(np.array(m), axis=1).round(2))
I don't know. This looks like another rounding issue. I used the numpy array mean and round functions and it works. Right now I don't know if the problem is rounding or the division operator.
Kevin Star Sorry but this note applies to all rounding levels: https://code.sololearn.com/cSmkN8fGY6dG/?ref=app Thanks for your advice but I've already solved this CCChallenge‼️🙂
can anyone help me with test case #1 at least to get the concept so that i can research the rest on my own. I’m really stuck. please
Erik Gordon-Quaicoe Read the PROBLEM again & all A in this Q&A‼️ Pay close attention to problems with round(), read about numpy mean & show me your code‼️😃
Janusz Bujak 🇵🇱 import numpy as np ls =  for i in range (2): ls.append(input().split()) ls_arr = np.array(ls) rm = ls_arr.astype(float) print (np.mean(rm, axis=1))
the Numpy has already a round function. n, p = [int(x) for x in input().split()] import numpy as np ls =  for i in range (n): ls.append(input().split()) ls_arr = np.array(ls) rm = ls_arr.astype(float) result = np.mean(rm, axis=1).round(2)
Data Science - the perfect solution for average of rows n, p = [int(x) for x in input().split()] import numpy as np rm =  for i in range(n): for a in input().split(): rm.append(float(a)) a = np.array(rm).reshape((n,p)) c = np.mean(a,axis=1) p = np.around(c,2) print(p)