Instagram
youtube
Facebook
Twitter

Element-wise Quotient with Transpose in NumPy

A Element-wise Quotient with Transpose in NumPy?
Code Explanation:
Library Import:
numpy is imported as np to access NumPy functions.
Array Creation: A 2D NumPy array arr is created with floating-point numbers.
Transpose Calculation: arr.T gives the transpose of the array, swapping rows with columns.
Element-wise Division: arr / arr.T divides each element of the original array by the corresponding element in its transpose.
Store Result: The resulting quotient array is stored in the variable quotient.
Display Output: print(quotient) prints the final quotient array.

 

Program:

import numpy as np

arr = np.array([[2.0, 4.0], [6.0, 8.0]])

quotient = arr / arr.T

print(quotient)