Instagram
youtube
Facebook
Twitter

Divide Two NumPy Arrays Element-wise

    Divide Two NumPy Arrays Element-wise
     
     Short Description of the Program:

     This program performs element-wise division of two NumPy arrays using the np.divide() function.
     
      Explanation:

  • np.array()
    Creates two arrays of the same shape containing numeric data.

     
  • np.divide(array1, array2)
    Divides each element in array1 by the corresponding element in array2.

     
  • print()
    Displays both input arrays and the result of the division.

     

Program:

import numpy as np

array1 = np.array([[1, 2, 3], [4, 5, 6]])

array2 = np.array([[10, 20, 30], [40, 50, 60]])

result = np.divide(array1, array2)

print("Array 1:\n", array1)

print("\nArray 2:\n", array2)

print("\nElement-wise Multiplication Result:\n", result)