Instagram
youtube
Facebook
Twitter

Compute the Transpose of a NumPy Array

   Compute the Transpose of a NumPy Array
    
    Short Description of the Program:

    This program computes the transpose of a NumPy array using the np.transpose() function.
    
     Explanation:

  • np.array()
    Creates a 2D array (matrix).

     
  • np.transpose(array)
    Flips the array over its diagonal — rows become columns and columns become rows.

     
  • print()
    Displays both the original and transposed arrays.

     

Program:

import numpy as np

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

transpose = np.transpose(array)

print("Original Array:\n", array)

print("\nTransposed Array:\n", transpose)