Articles → NUMPY → Adding 2 Arrays Item By Item In Numpy

Adding 2 Arrays Item By Item In Numpy






Example






import numpy as np

arr = np.arange(1, 10)

print("Print Array before addition:", arr)

arr = arr + arr

print("Print Array after addition:", arr)




Picture showing the output when 2 arrays are added
Click to Enlarge



import numpy as np

arr = np.arange(1, 10)

print("Print Array before subtraction:", arr)

arr = arr - arr

print("Print Array after subtraction:", arr)


Picture showing the output when 2 arrays are substracted
Click to Enlarge



import numpy as np

arr = np.arange(1,10)

print("Print Array before multiplication:", arr)

arr = arr * arr

print("Print Array after multiplication:", arr)


Picture showing the output when 2 arrays are multiplied
Click to Enlarge



import numpy as np

arr = np.arange(1,10)

print("Print Array before division:", arr)

arr = arr / arr

print("Print Array after division:", arr)


Picture showing the output when 2 arrays are divided
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Monday, April 1, 2019

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250