🔵 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

TermMeaning
ndarrayMain NumPy array object.
arrayEfficient collection of same-type numerical values.
shapeDimensions of an array.
dtypedtype is an important term in this topic.
vectorizationPerforming 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 np imports 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

  1. Program ko numpy-arrays.py file me type karke run karein.
  2. Values change karke output compare karein.
  3. fast numeric calculation par ek छोटा example banayen.
  4. 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.

← Back to Python Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

💻 लाइव कोड एडिटर

इस पेज के प्रोग्राम यहीं तैयार हैं — चलाएँ, बदलें और सीखें। कुछ भी इंस्टॉल किए बिना।
OneCompiler द्वारा संचालित। कोड एडिटर में अपने आप आ जाता है — Run दबाकर आउटपुट देखें। अगर एडिटर न खुले तो नए टैब में खोलें.