Saturday, November 22, 2025
HomeLanguagesnumpy.ndarray.size() method | Python

numpy.ndarray.size() method | Python

numpy.ndarray.size() function return the number of elements in the array. it equal to np.prod(a.shape), i.e., the product of the array’s dimensions.

Syntax : numpy.ndarray.size(arr)

Parameters :
arr : [array_like] Input array.

Return : [int] The number of elements in the array.

Code #1 :




# Python program explaining
# numpy.ndarray.size() function
  
# importing numpy as geek 
import numpy as geek
  
arr = geek.zeros((3, 4, 2), dtype = geek.complex128)
  
gfg = arr.size
  
print (gfg)


Output :

24

 
Code #2 :




# Python program explaining
# numpy.ndarray.size() function
  
# importing numpy as geek 
import numpy as geek
  
arr = geek.zeros((3, 4, 2), dtype = geek.complex128)
  
gfg = geek.prod(arr.shape)
  
print (gfg)


Output :

24
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32407 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6784 POSTS0 COMMENTS
Nicole Veronica
11931 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11999 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7168 POSTS0 COMMENTS
Thapelo Manthata
6863 POSTS0 COMMENTS
Umr Jansen
6848 POSTS0 COMMENTS