NumPy Basics 🐍📊 NumPy (Numerical Python) is the most important…

✅ NumPy Basics 🐍📊

NumPy (Numerical Python) is the most important library for numerical computing in Python.

It is widely used in:
✔ Data Science
✔ Machine Learning
✔ AI
✔ Scientific computing

🔹 1. What is NumPy?

NumPy provides a powerful data structure called NumPy Array. It is faster and more efficient than Python lists for mathematical operations.

Example:
import numpy as np


🔹 2. Creating a NumPy Array

From a List

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


Output:
[1 2 3 4]


🔹 3. Check Array Type

print(type(arr))


Output:
<class 'numpy.ndarray'>


🔹 4. NumPy Array Operations

Addition:

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


Output:
[3 4 5]


Multiplication:
print(arr * 2)


Output:
[2 4 6]


🔹 5. NumPy Built-in Functions

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


Output:
100
25.0
40
10


🔹 6. NumPy Array Shape

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


Output:
(2, 3)


Meaning: 2 rows and 3 columns.

🔹 7. Why NumPy is Important?

NumPy is the foundation of data science libraries:
✔ Pandas
✔ Scikit-Learn
✔ TensorFlow
✔ PyTorch

All these libraries use NumPy internally.

🎯 Today's Goal
✔ Install NumPy
✔ Create arrays
✔ Perform math operations
✔ Understand array shape

Double Tap ♥️ For More
❤16
November 21, 2026 1.5K