Program to check whether the dimensions of two arrays are the same or not

In this python numpy program, we will check whether the dimensions of two arrays are the same or not.

Steps to solve the program
  1. Import the numpy library as np.
  2. Create two arrays using np.array().
  3. Use an if-else statement with shape to check whether the dimensions of two arrays are the same or not.
  4. Print the output.
				
					import numpy as np
x = np.arange(15).reshape(3,5)
y = np.arange(20).reshape(4,5)

if x.shape == y.shape:
    print("Same dimensions")
else:
    print("Different dimensions")
				
			

Output :

				
					Different dimensions
				
			

Create an array and reshape it.

calculate the sin angle of an array.

Leave a Comment