Locked lesson.
About this lesson
Let's discuss mathematical operations we can use in Numpy, including scalars.
Exercise files
Download this lesson’s related exercise files.
Numpy Operations.docx57.2 KB Numpy Operations - Solution.docx
55.5 KB
Quick reference
Numpy Operations
There are two main Numpy Math Operations; Array with Array Operations, and Scalar Operations.
When to use
Use these when you want to do math to the elements of your Numpy Array.
Instructions
To add, subtract, multiply or divide an array to itself: (given an array called my_arr)
my_arr + my_arr
my_arr - my_arr
my_arr * my_arr
my_arr / my_arr
To add, subtract, multiply or divide an array to any number: (given an array called my_arr)
my_arr + 100
my_arr - 100
my_arr * 100
my_arr / 100
You can use any Python math operators with either method.
Hints & tips
- Array With Array Operations: my_arr + my_arr
- Array With Scalar Operations: my_arr + 100
Lesson notes are only available for subscribers.