NumPy Arrays
NumPy Arrays
What are NumPy Arrays?
NumPy Arrays means numPy arrays store numerical data efficiently and support fast mathematical operations.
In real programs, this topic helps in fast numeric calculation. Learn the idea first, then type the program yourself and compare the output.
| Point | Details |
|---|---|
| Course Area | Data Science Tools and concepts used to analyse, clean and present data. |
| Main Use | fast numeric calculation |
| Example File | numpy-arrays.py |
| Practice Focus | Run, change values, and explain the output line by line. |
Why should you learn this?
- It is useful for fast numeric calculation.
- It connects with matrix/vector operations.
- It improves your ability to read, write and debug Python programs.
Important Terms
These terms are used directly in this lesson. Understand them before memorising the code.
| 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
The simple pattern is: prepare data, apply the concept, then show the result.
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
import numpy as np
marks = np.array([78, 85, 91, 66])
print(marks)
print("Mean:", marks.mean())
print("After bonus:", marks + 5)Expected Output
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.
Where will you use it?
- 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
- Type the program in
numpy-arrays.pyand run it. - Change input values or sample data and observe the new output.
- Create one example related to fast numeric calculation.
- Write 5 lines explaining the logic in your own words.
Summary
NumPy Arrays is not a theory-only topic. You should be able to explain the meaning, write the example, run it successfully, and use it in a small practical program.
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 करें.
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
import numpy as np
marks = np.array([78, 85, 91, 66])
print(marks)
print("Mean:", marks.mean())
print("After bonus:", marks + 5)Expected Output
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.