Python Forum
How to solve problem 1181 of the URI with numpy. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: How to solve problem 1181 of the URI with numpy. (/thread-33007.html)



How to solve problem 1181 of the URI with numpy. - thiagohps - Mar-22-2021

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/pt/problems/view/1181


RE: How to solve problem 1181 of the URI with numpy. - deanhystad - Mar-22-2021

What have you tried so far?


RE: How to solve problem 1181 of the URI with numpy. - thiagohps - Mar-22-2021

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)



RE: How to solve problem 1181 of the URI with numpy. - deanhystad - Mar-22-2021

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?


RE: How to solve problem 1181 of the URI with numpy. - buran - Mar-22-2021

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.