Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python NumPy Shape function example Printing the shape of the multidimensional array

# Welcome to softhunt.net
import numpy as npy
 
# creating a 2-d array
arr1 = npy.array([[4, 5, 6, 7], [1, 2, 3, 4]])
 
# creating a 3-d array
arr2 = npy.array([[[8, 7], [6, 5]], [[4, 3], [2, 1]]])
 
# printing the shape of arrays
# first element of tuple gives
# dimension of arrays second
# element of tuple gives number
# of element of each dimension
print(arr1.shape)
print(arr2.shape)
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Python #NumPy #Shape #function #Printing #shape #multidimensional #array
ADD COMMENT
Topic
Name
4+8 =