Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array Mathamatics ( hackerrank - python) #4

Open
dilanmelvin opened this issue Oct 4, 2024 · 0 comments
Open

Array Mathamatics ( hackerrank - python) #4

dilanmelvin opened this issue Oct 4, 2024 · 0 comments

Comments

@dilanmelvin
Copy link

import numpy as np

Input the number of rows and columns

elements = input().split()
int_elements = list(map(int, elements))

Input first matrix

n_A = []
for i in range(int_elements[0]):
n_A.append(list(map(int, input().split())))

Input second matrix

m_B = []
for i in range(int_elements[0]):
m_B.append(list(map(int, input().split())))

Convert the lists to NumPy arrays

a = np.array(n_A)
b = np.array(m_B)

Perform element-wise operations and print the results

print(np.add(a, b))
print(np.subtract(a, b))
print(np.multiply(a, b))
print(np.floor_divide(a, b)) # Perform integer division
print(np.mod(a, b))
print(np.power(a, b))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant