We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
importnumpyasnpn,m=map(int,input().split())arrays=[]#containsalltheinputsforcomputetry:whileTrue:arr=input()ifnotarr:breakarrays.append(list(map(int,arr.split())))exceptEOFError:pass# handles both 2d and 1d arraysifn==1:a=np.array(arrays[0])b=np.array(arrays[1])else:a=np.array(arrays[:2]).reshape(n,m)b=np.array(arrays[2:]).reshape(n,m)actions=["add","subtract","multiply","floor_divide","mod","power"]foractioninactions:result=getattr(np,action)(a,b)ifn==1:print(f"[{result}]")else:print(f"{result}")
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Array Mathematics
You are viewing a single comment's thread. Return to all comments →