1D Indexing कैसे करें
position से एक element पाने के लिए square brackets में एक number इस्तेमाल करें, zero से शुरू होते हुए।
In this page:
Syntax
arr[index]
arr[-1]
1D Indexing
एक 1-D array index करना एक list जैसे काम करता है: arr[0] पहला element है। array को in place modify करने के लिए आप एक index को assign भी कर सकते हैं। अंत से आगे जाना IndexError raise करता है।
Note:
Indexing एक NumPy scalar return करता है जैसे np.int64, एक plain Python int नहीं।
उदाहरण: 1D indexing
import numpy as np
a = np.array([10, 20, 30, 40])
print(a[0], a[2])
a[1] = 99
print(a)
# Output:
# 10 30
# [10 99 30 40]
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. #}
आम गलतियां
- 0 की बजाय 1 से शुरू करना
- last element से आगे index करना
- यह भूल जाना कि assignment original array बदलता है
चैप्टर सारांश
- Indices 0 से शुरू होती हैं
- arr[i] एक element पढ़ता या assign करता है
- Out-of-range IndexError raise करता है
- Results NumPy scalars हैं
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: