Python Interview questions - numpy
(Python 3.9 or later/numpy 1.20 or later)
What is the difference between a numpy array (ndarray) and matrix?
matrix objects are strictly multi-dimensional while ndarray objects can only be 2-dimensional
matrix objects are strictly 3-dimensional while ndarray objects can be multi-dimensional
matrix objects are strictly 2-dimensional while ndarray objects can be multi-dimensional
matrix objects are strictly 1-dimensional while ndarray objects can only be 2-dimensional
Which of the following is NOT a difference between a list and a numpy array (ndarray)?
All arithmetic operations are supported and they are element-wise for a list; Some arithmetic operations are supported and they are not element-wise for an array
A list is a container of objects and can hold elements of different data types; An array is a container of objects and can hold elements of the same data type only
Lists are built-in data types in python, so no import is needed to use them; Arrays are not built-in data types in python, so an import is needed to use them
A list is flexible and can be changed after its creation; Once an array is defined, its size is fixed and cannot be changed
gk