NumPy Side Effects
numpy
is great for doing vector arithmetic. If you compare its functionality with regular Python lists, however, some things have changed.
First of all, numpy
arrays cannot contain elements with different types.
Second, the typical arithmetic operators, such as +
, -
, *
and /
have a different meaning for regular Python lists and numpy
arrays.
Some lines of code have been provided for you. Try these out and select the one that would match this:
np.array([True, 1, 2]) + np.array([3, 4, False])
The numpy
package is already imported as np
.
This exercise is part of the course
Introduction to Python
Hands-on interactive exercise
Turn theory into action with one of our interactive exercises
