Python Forum
How to solve problem 1181 of the URI with numpy.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to solve problem 1181 of the URI with numpy.
#1
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
Reply
#2
What have you tried so far?
Reply
#3
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)
buran write Mar-22-2021, 04:09 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply
#4
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?
Reply
#5
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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to solve this problem Python configuration? magomes 5 212 Mar-22-2024, 11:11 PM
Last Post: magomes
Star Interesting Intro to python problem I can't solve. Honestworker 5 12,161 Mar-04-2021, 02:05 AM
Last Post: BashBedlam
  solve probability problem by python Dreammer 1 1,814 Dec-24-2020, 09:51 AM
Last Post: Larz60+
  numpy problem nats 0 1,795 Jan-12-2020, 02:54 PM
Last Post: nats
  Algorithm to solve a case of Travelling Salesman Problem Ale888 3 2,946 Dec-11-2018, 07:49 PM
Last Post: buran
  how to solve this problem. IndexError: axis 2 out of bounds [0, 2) bedio 10 8,845 Nov-21-2017, 02:47 PM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020