🎓 All Courses | 📚 Python Programming Syllabus

📋 Study this course on TaskLoco
#python-programming#numpy#data-science

NumPy — Fast Numerical Computing

NumPy provides fast multi-dimensional arrays. Foundation of data science in Python. Install: pip install numpy.


import numpy as np

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

Array operations (vectorized — no loops needed):

arr * 2          # [2, 4, 6, 8, 10]
arr + 10         # [11, 12, 13, 14, 15]
arr ** 2         # [1, 4, 9, 16, 25]
np.sqrt(arr)     # square root of each
np.sum(arr)      # 15
np.mean(arr)     # 3.0

Creating arrays:

np.zeros((3, 4))     # 3x4 matrix of zeros
np.ones((2, 3))      # 2x3 matrix of ones
np.arange(0, 10, 2)  # [0, 2, 4, 6, 8]
np.linspace(0, 1, 5) # 5 evenly spaced points

Indexing:

matrix[0]        # first row
matrix[:, 1]     # second column
matrix[0, 2]     # row 0, col 2

Why NumPy: 10-100x faster than Python lists for numerical operations because it uses C under the hood.


YouTube • Top 10
Python Programming: NumPy Basics
Tap to Watch ›
📸
Google Images • Top 10
Python Programming: NumPy Basics
Tap to View ›

Reference:

Wikipedia: NumPy

image for linkhttps://en.wikipedia.org/wiki/NumPy

📚 Python Programming — Full Course Syllabus
📋 Study this course on TaskLoco

TaskLoco™ — The Sticky Note GOAT