# Shape() function in Numpy Python by R4R Team

- shape() is Python Numpy method that find or return the actual shape of the given Array.
- It return the order of the matrix.

Example-

array is [1 2]
Shape is (2,)

array is
[[1,2]
[3,4]]
Shape is (2,2)

Syntax-

shape=numpy.shape(array)

program-

#import numpy
import numpy as np

l=[1,2,3,4]
arr=np.array(l)
print("Array isn",arr)
print("And Shape is",arr.shape)

l=[[1,2,3],[3,2,1],[1,0,1]]
arr=np.array(l)
print("nArray isn",arr)
print("And Shape is",arr.shape)

l=[[[1,2],[2,1]],[[3,4],[4,3]]]
arr=np.array(l)
print("nArray isn",arr)
print("And Shape is",arr.shape)

output-

Array is
[1 2 3 4]
And Shape is (4,)

Array is
[[1 2 3]
[3 2 1]
[1 0 1]]
And Shape is (3, 3)

Array is
[[[1 2]
[2 1]]

[[3 4]
[4 3]]]
And Shape is (2, 2, 2)

-In this program, we have three different list then we convert them into array of one,two and three dimension.
-Then by shape(array), we find the shape or order of the array.

##### R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!