← Back to NumPy Course | Chapter 3: Array Attributes | Lesson 3 of 6

size क्या है

size array में elements की total count है, चाहे इसकी कितनी भी dimensions हों।

In this page:

  1. size
Syntax
python
arr.size

size

size सारी shape entries को साथ multiply करता है। एक (3, 4) array का size 12 है। यह len() से अलग है, जो सिर्फ पहली axis की length return करता है।

Note: यह check करने के लिए arr.size इस्तेमाल करें कि एक reshape target exactly same संख्या elements hold करता है।

उदाहरण: size

python
import numpy as np

m = np.zeros((3, 4))
print("size:", m.size)
print("len:", len(m))
print("shape product:", m.shape[0] * m.shape[1])

# Output:
# size: 12
# len: 3
# shape product: 12
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. len() इस्तेमाल करना और total element count की उम्मीद करना
  2. एक ऐसे shape में reshape करना जिसका product size से अलग हो
  3. size को एक function की तरह call करना
चैप्टर सारांश
  • size elements की total संख्या है
  • यह shape का product है
  • len सिर्फ पहली axis return करता है
  • यह एक attribute है
🔒

Chapter Quiz — Complete all 6 topics to unlock

0/6 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.