Feedback Form

Arrays & Array Operations in NumPy in hindi

Arrays & Array Operations in NumPy in Hindi – Complete Guide

Table of Contents – Arrays & Array Operations in NumPy in Hindi

Arrays & Array Operations in NumPy in Hindi

NumPy Arrays in Hindi

जब हम Python में data को efficiently store और process करना चाहते हैं, तब NumPy Arrays सबसे important concept बन जाते हैं। College exams, practicals और competitive exams में NumPy Array से directly questions पूछे जाते हैं, इसलिए इसे clear समझना बहुत ज़रूरी है। NumPy का पूरा नाम Numerical Python है और इसका core feature ही Array होता है।

Simple शब्दों में कहें तो NumPy Array एक ऐसा data structure है जिसमें एक ही type के multiple values store होते हैं। Python list के मुकाबले NumPy Arrays fast होते हैं, कम memory लेते हैं और mathematical operations के लिए specially designed होते हैं। इसी वजह से Data Science, Machine Learning और Scientific Computing में NumPy का use किया जाता है।

What is NumPy Array

NumPy Array एक homogeneous data structure होता है, मतलब इसमें सभी elements एक ही data type के होते हैं। जैसे अगर array में integers हैं तो सारे elements integer ही होंगे। यह feature exam point of view से बहुत important है।

Python list heterogeneous होती है लेकिन NumPy Array homogeneous होता है, यही सबसे बड़ा difference है। इस वजह से NumPy Array ज्यादा optimized और fast perform करता है।

Why NumPy Arrays are Important

College level पर जब numerical problems, matrix या statistical calculation आते हैं, तब NumPy Arrays का use किया जाता है। Manual calculation या Python list से ऐसे operations slow और complex हो जाते हैं। NumPy Array इन problems को simple बना देता है।

  • Large amount of numerical data को fast process करता है
  • Mathematical और statistical operations easy बनाता है
  • Machine Learning और Data Analysis का base है
  • Exam में direct theory और practical questions आते हैं

Creating NumPy Array

NumPy Array बनाने के लिए सबसे पहले NumPy library को import करना पड़ता है। Exams में यह syntax कई बार पूछा जाता है।

Basic array create करने के लिए array() function का use किया जाता है।

import numpy as np arr = np.array([1, 2, 3, 4, 5])

यहाँ arr एक one-dimensional NumPy Array है। इस array में सभी values integer type की हैं।

Types of NumPy Arrays

NumPy में arrays को उनके dimensions के आधार पर classify किया जाता है। Exam में अक्सर पूछा जाता है कि NumPy Array के कितने types होते हैं।

  • One Dimensional Array
  • Two Dimensional Array
  • Multi Dimensional Array

One Dimensional Array

One Dimensional Array simple list की तरह होता है जिसमें rows या columns का concept नहीं होता। यह linear form में data store करता है।

arr1 = np.array([10, 20, 30])

यह array basic operations और examples के लिए use किया जाता है। College exams में introductory questions इसी से आते हैं।

Two Dimensional Array

Two Dimensional Array rows और columns में data store करता है। इसे matrix भी कहा जाता है। Mathematics और engineering subjects में इसका use बहुत common है।

arr2 = np.array([[1, 2, 3], [4, 5, 6]])

यहाँ 2 rows और 3 columns हैं। Exam में matrix representation और indexing इसी concept पर based होती है।

Multi Dimensional Array

जब array में दो से ज्यादा dimensions होती हैं, तब उसे Multi Dimensional Array कहते हैं। Data Science और Machine Learning में complex data को represent करने के लिए इसका use होता है।

हालाँकि college exams में इसका theoretical concept ज्यादा पूछा जाता है।

Array Attributes

NumPy Arrays के कुछ important attributes होते हैं जो array की information देते हैं। Exam में इन attributes के नाम और use पूछे जाते हैं।

Attribute Use
ndim Array की dimensions बताता है
shape Rows और columns की information देता है
size Total elements की संख्या बताता है
dtype Array का data type बताता है

Example of Array Attributes

arr = np.array([[1, 2], [3, 4]]) print(arr.ndim) print(arr.shape) print(arr.size) print(arr.dtype)

यह code array की complete internal information दिखाता है। Practical exams में ऐसे छोटे programs लिखने को मिलते हैं।

Difference Between List and NumPy Array

Exam में अक्सर पूछा जाता है कि Python List और NumPy Array में difference लिखिए। इसलिए यह concept clear होना चाहिए।

Python List NumPy Array
Heterogeneous होती है Homogeneous होती है
Slow performance Fast performance
More memory use Less memory use
Basic operations Advanced mathematical operations

Real Life Use of NumPy Arrays

NumPy Arrays का use सिर्फ exams तक limited नहीं है। Real life में weather data analysis, image processing और financial calculations में इसका use होता है।

जब large numerical data को fast calculate करना होता है, तब NumPy Arrays best option होते हैं। इसलिए students के लिए इसे अच्छे से समझना future perspective से भी बहुत important है।

Array Operations in NumPy in Hindi

NumPy Arrays समझने के बाद अगला सबसे important topic है Array Operations। College exams, practical files और viva में ज़्यादातर questions इन्हीं operations से पूछे जाते हैं। अगर तुम्हें array operations clear हैं, तो NumPy का बड़ा हिस्सा अपने-आप easy हो जाता है।

Array Operations का मतलब है array पर mathematical, logical और structural operations perform करना। NumPy इन operations को बहुत fast और simple बना देता है।

Basic Arithmetic Operations

NumPy में arithmetic operations element-wise perform होते हैं। मतलब array के हर element पर operation apply होता है। यह feature exams में directly पूछा जाता है।

  • Addition
  • Subtraction
  • Multiplication
  • Division
import numpy as np a = np.array([10, 20, 30]) b = np.array([1, 2, 3]) print(a + b) print(a - b) print(a * b) print(a / b)

यहाँ हर element अपने corresponding element के साथ operate कर रहा है। Python list में ऐसा directly possible नहीं है।

Scalar Operations

जब किसी array के हर element पर एक ही value apply की जाती है, उसे scalar operation कहते हैं। यह numerical problems में बहुत use होता है।

arr = np.array([2, 4, 6]) print(arr + 2) print(arr * 3)

यह operation fast calculation के लिए बहुत useful है। Exams में short programs में scalar operations अक्सर दिखते हैं।

Comparison Operations

NumPy arrays पर comparison operations भी element-wise होते हैं। इनका result boolean array के रूप में मिलता है।

arr = np.array([5, 10, 15]) print(arr > 8) print(arr == 10)

इसका use filtering और condition based selection में किया जाता है। Data Analysis में यह concept बहुत important है।

Logical Operations

Logical operations multiple conditions को combine करने के लिए use होते हैं। यह operations boolean arrays पर apply होते हैं।

  • logical_and
  • logical_or
  • logical_not
a = np.array([True, False, True]) b = np.array([False, False, True]) print(np.logical_and(a, b)) print(np.logical_or(a, b))

College exams में logical functions के नाम और use theoretical form में भी पूछे जाते हैं।

Indexing and Slicing Operations

Array Operations का सबसे important हिस्सा indexing और slicing है। इसी से हम array के specific elements या portion को access करते हैं।

Indexing

Indexing का मतलब है array के किसी particular element को access करना। Index हमेशा 0 से start होता है।

arr = np.array([100, 200, 300]) print(arr[0]) print(arr[2])

Two Dimensional Array में row और column दोनों specify करने पड़ते हैं।

arr2 = np.array([[1, 2], [3, 4]]) print(arr2[0, 1])

Slicing

Slicing का मतलब है array का एक part निकालना। यह syntax Python list जैसा ही होता है।

arr = np.array([10, 20, 30, 40, 50]) print(arr[1:4])

Slicing exams में बहुत common topic है। Students से output predict करने को कहा जाता है।

Shape Changing Operations

NumPy हमें array का shape change करने की facility देता है। Same data को अलग-अलग structure में represent किया जा सकता है।

reshape()

reshape() function array का shape change करता है बिना data बदले।

arr = np.array([1, 2, 3, 4, 5, 6]) new_arr = arr.reshape(2, 3) print(new_arr)

Exam में reshape के output से related questions पूछे जाते हैं।

flatten()

flatten() function multi dimensional array को one dimensional बना देता है।

arr = np.array([[1, 2], [3, 4]]) print(arr.flatten())

Aggregation Operations

Aggregation operations पूरे array पर calculation perform करते हैं। Statistics और numerical problems में इनका use होता है।

  • sum()
  • mean()
  • max()
  • min()
arr = np.array([10, 20, 30]) print(arr.sum()) print(arr.mean()) print(arr.max()) print(arr.min())

Mean, max और min exams में theory और practical दोनों में आते हैं।

Sorting Operations

NumPy arrays को sort करना बहुत easy है। Sorted data analysis में ज्यादा readable और useful होता है।

arr = np.array([40, 10, 30, 20]) print(np.sort(arr))

यह function ascending order में sort करता है। Sorting से related short notes exams में पूछे जाते हैं।

Copy vs View Operations

यह concept थोड़ा tricky होता है लेकिन exam point of view से बहुत important है। Copy में new array बनता है, जबकि view original array से जुड़ा रहता है।

arr = np.array([1, 2, 3]) copy_arr = arr.copy() view_arr = arr.view()

अगर original array change होगा, तो view भी change होगा लेकिन copy नहीं। इस difference को theory question में पूछा जाता है।

Why Array Operations are Important for Exams

Array Operations से students की logical understanding check की जाती है। इसलिए output based questions, short programs और theory questions सब आते हैं।

अगर तुम NumPy Array Operations अच्छे से practice कर लेते हो, तो Data Science, Machine Learning और Python practicals अपने-आप strong हो जाते हैं।

FAQs

आपका अगला टॉपिक पढ़े Indexing & Slicing in NumPy in hindi

NumPy Array एक special data structure होता है जिसमें एक ही data type के multiple values store की जाती हैं। इसे numerical calculation को fast और easy बनाने के लिए design किया गया है। Python list के comparison में NumPy Array ज्यादा fast और memory efficient होता है।

Python List heterogeneous होती है यानी इसमें अलग-अलग data types हो सकते हैं, जबकि NumPy Array homogeneous होता है। NumPy Array mathematical और statistical operations के लिए ज्यादा suitable होता है, इसलिए exams और practicals में NumPy Array को prefer किया जाता है।

Array Operations का मतलब है array पर different calculations perform करना, जैसे addition, subtraction, multiplication, division, sorting और reshaping। ये operations element-wise होते हैं और large data को easily handle करते हैं।

Indexing का use array के किसी specific element को access करने के लिए किया जाता है, जबकि slicing से array का एक part निकाला जाता है। Index हमेशा 0 से start होता है और slicing Python list जैसी ही होती है।

reshape() function array का shape change करता है बिना data बदले, जबकि flatten() function multi dimensional array को one dimensional बना देता है। ये दोनों functions exams में output based questions के लिए बहुत important होते हैं।

NumPy Arrays से numerical problems, matrix operations और statistical calculations easily solve होते हैं। Theory, practical और viva में NumPy Arrays और Array Operations से direct questions पूछे जाते हैं, इसलिए students के लिए यह topic exam point of view से बहुत important है।