Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Mathematical Operati | Master Data Science with Python lesso | BraveProgrammer
  1. Courses
  2. /
  3. Master Data Science with Python

Lesson 10 of 60

·python

Mathematical Operations with NumPy

25 minutes

Course progress17%

Mathematical Operations

NumPy provides a rich set of universal functions (ufuncs) for element‑wise math.

Basic arithmetic

x = np.array([1, 2, 3])
y = np.array([4, 5, 6])
print(x + y)   
(x * y)   
(x ** )  
# [5 7 9]
print
# [4 10 18]
print
2
# [1 4 9]

Trigonometric functions

angles = np.deg2rad(np.array([0, 30, 45, 60, 90]))
print(np.sin(angles))

Aggregations

arr = np.random.randn(1000)
print("Mean:", arr.mean())
print("Std:", arr.std())
print("Median:", np.median(arr))

Linear Algebra utilities

A = np.array([[1, 2], [3, 4]])
B = np.linalg.inv(A)
print("Inverse of A:
", B)
print("Determinant:", np.linalg.det(A))

Random sampling

rng = np.random.default_rng(seed=42)
samples = rng.normal(loc=0, scale=1, size=5)
print(samples)

Info

Use np.dot or the @ operator for matrix multiplication.
Make it stickPractice what you've learned1 quiz · 4 practical tests · Optional activities from Master Data Science with PythonBrowse activities
Previous lessonBroadcasting in NumPyContinue to lesson 11Random Sampling and Statistics with NumPyBack to Master Data Science with Python curriculum