Array Calculations
- 01:09
How calculations between two arrays are performed on corresponding elements.
Downloads
No associated resources to download.
Glossary
NumPy Numpy arrays PythonTranscript
When you perform calculations between two arrays, the calculation occurs between corresponding objects in each of the arrays. For example, here we have array X 1, 2, 3, and 4. That's a two-by-two array and another two-by-two array array Y containing 5, 6, 7, and 8. In this cell, I've created array Z, which is array X plus array Y. When I use that addition operator and create array Z and print array Z, you can see that I have 6, 8, 10, and 12. So my one in the top left has been added to the 5 in the top left of array Y to make 6. Two has been added to 6 for 8, 3 has been added to 7 for 10, and 4 has been added to 8 for 12.
If I try to perform a calculation between an array and a number, like here how I have array Z plus 10, you're gonna see that that tin is added to each object in the array.