NumPy Interview Questions and Answers
Experienced / Expert level questions & answers
Ques 1. What is the purpose of np.newaxis in NumPy?
np.newaxis is used to increase the dimension of the existing array by one more dimension when used once.
Ques 2. Explain the differences between np.dot() and np.matmul() in NumPy.
np.dot() performs matrix multiplication for 2-D arrays, while np.matmul() is equivalent to the '@' operator and is more general.
Ques 3. Create a diagonal matrix using NumPy.
import numpy as npnarr = np.diag([1, 2, 3])
Ques 4. Explain the purpose of np.meshgrid() in NumPy.
np.meshgrid() is used to create coordinate matrices from coordinate vectors, commonly used for 3D plotting.
Ques 5. Explain the use of 'np.histogram()' in NumPy.
'np.histogram()' computes the histogram of a set of data, returning the bin counts and bin edges.
Ques 6. How to find the index of the maximum value in a NumPy array?
You can use 'np.argmax()'. For example, 'np.argmax(arr)' returns the index of the maximum value in 'arr'.
Ques 7. What is the purpose of 'np.where()' in NumPy?
'np.where()' returns the indices of elements that satisfy a given condition.
Ques 8. Explain the use of 'np.linalg.inv()' in NumPy.
'np.linalg.inv()' computes the (multiplicative) inverse of a matrix.
Ques 9. What is the purpose of 'np.percentile()' in NumPy?
'np.percentile()' calculates the nth percentile of a dataset.
Ques 10. Explain the use of 'np.unique()' in NumPy.
'np.unique()' returns the unique elements of an array.
Ques 11. How to transpose a NumPy array?
You can use 'arr.T'. For example, 'transposed_arr = arr.T'.
Most helpful rated by users:
Related interview subjects
NumPy interview questions and answers - Total 30 questions |
Python interview questions and answers - Total 106 questions |
Python Pandas interview questions and answers - Total 48 questions |
Python Matplotlib interview questions and answers - Total 30 questions |
Django interview questions and answers - Total 50 questions |
Pandas interview questions and answers - Total 30 questions |
Deep Learning interview questions and answers - Total 29 questions |
PySpark interview questions and answers - Total 30 questions |
Flask interview questions and answers - Total 40 questions |
PyTorch interview questions and answers - Total 25 questions |
Data Science interview questions and answers - Total 23 questions |
SciPy interview questions and answers - Total 30 questions |
Generative AI interview questions and answers - Total 30 questions |