🔵 Data Science · Lesson 35
NumPy Arrays
NumPy Arrays क्या है?
NumPy Arrays ka matlab hai: NumPy arrays store numerical data efficiently and support fast mathematical operations. Simple words me, ye topic practical Python programs likhne me direct use hota hai.
Is topic ko sirf definition ke liye nahi, balki fast numeric calculation jaise real examples ke liye practice karein.
यह क्यों सीखना जरूरी है?
- Ye fast numeric calculation me kaam aata hai.
- Ye matrix/vector operations se bhi connected hai.
- Isse aap code ka output aur errors better samajh paate hain.
Important Terms
| Term | Meaning |
|---|---|
| ndarray | Main NumPy array object. |
| array | Efficient collection of same-type numerical values. |
| shape | Dimensions of an array. |
| dtype | dtype is an important term in this topic. |
| vectorization | Performing operations on whole arrays without Python loops. |
Syntax / Basic Pattern
Basic idea: pehle data तैयार करें, phir Python logic apply करें, aur finally result display करें.
Basic Pattern
import numpy as np
marks = np.array([78, 85, 91, 66])
print(marks)
print("Mean:", marks.mean())
print("After bonus:", marks + 5)Complete Example Program
Python – numpy-arrays.py
import numpy as np
marks = np.array([78, 85, 91, 66])
print(marks)
print("Mean:", marks.mean())
print("After bonus:", marks + 5)Expected Output
[78 85 91 66]
Mean: 80.0
After bonus: [83 90 96 71]
Program Explanation
import numpy as npimports ready-made features from a module/library.marks = np.array([78, 85, 91, 66])stores a value in marks.print(marks)displays information or calculated result on the screen.print("Mean:", marks.mean())displays information or calculated result on the screen.print("After bonus:", marks + 5)displays information or calculated result on the screen.
Practical Uses
- Fast numeric calculation.
- Matrix/vector operations.
- Preparing data for ml.
Common Mistakes
- Analysing data before checking missing values, duplicates and data types.
- Changing original data without keeping a clean copy.
- Creating charts without title, labels or explanation.
Practice Tasks
- Program ko
numpy-arrays.pyfile me type karke run karein. - Values change karke output compare karein.
- fast numeric calculation par ek छोटा example banayen.
- Logic ko apne words me 5 lines me likhein.
सारांश
NumPy Arrays ko tab complete maanenge jab aap iska meaning, example, output aur practical use clearly explain kar saken.
💻 लाइव कोड एडिटर
इस पेज के प्रोग्राम यहीं तैयार हैं — चलाएँ, बदलें और सीखें। कुछ भी इंस्टॉल किए बिना।
OneCompiler द्वारा संचालित। कोड एडिटर में अपने आप आ जाता है — Run दबाकर आउटपुट देखें। अगर एडिटर न खुले तो नए टैब में खोलें.