Arithmetic Operations on NumPy Arrays

Machine Learning courses with 100+ Real-time projects Start Now!!

Program 1

import numpy as np
ar1=np.array([[10,15,30],[30,45,50],[60,76,80]])
ar2=np.array([[1,2,3],[4,5,6],[7,8,9]])
print(ar1)
print(ar1.shape)
print("------------------------")
print(ar2)
print(ar2.shape)
print(ar1+ar2)
print(ar1-ar2)
print(ar1/ar2)
print(ar1//ar2)
print(ar1%10)

# ar3=np.add(ar1,ar2)
# print(ar3)
# ar3=np.subtract(ar1,ar2)
# print(ar3)
# ar3=np.multiply(ar1,ar2)
# print(ar3)
# ar3=np.divide(ar1,ar2)
# print(ar3)
# ar3=np.mod(ar1,10)
# print(ar3)
# ar4=np.array([0.5,0.8,0.6])
# ar3=np.reciprocal(ar4)
# print(ar3)

 

If you are Happy with DataFlair, do not forget to make us happy with your positive feedback on Google

courses

TechVidvan Team

TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.

Leave a Reply

Your email address will not be published. Required fields are marked *