Python Forum

Full Version: How to solve problem 1181 of the URI with numpy.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm new to python and I don't know how I can solve this type of problem using numpy.

Could someone help me.

Link: https://www.urionlinejudge.com.br/judge/.../view/1181
What have you tried so far?
I only know how to work this way I tried to understand the numpy library more without success.

l = int (input ())
opera = input ()
  

m = []
for i in range (12):
     m.append ([])

for i in range (12):
     for j in range (12):
         x = float (input ())
         m [i] .append (x)
       

if opera == 'S':
     sum = 0
     for k in m [l]:
         sum = sum + k
     print (sum)
if opera == 'M':
     med = 0
     sum = 0
     for k in m [l]:
         sum = sum + k
     med = sum / 12
     print (med)
Please wrap code in Python tags to retain the indentation.

So all you need to do is replace your list of lists with a 2D numpy array and use numpy functions to compute sum and med?
sum is built-in function, don't use it as name.
If we solve it for you using numpy you still will not know numpy - i.e. this is not really helpful.