Intermediate / 1 to 5 years experienced level questions
Intermediate / 1 to 5 years experienced level questions & answers
Ques 1. Explain broadcasting in NumPy.
Broadcasting is a powerful mechanism that allows NumPy to work with arrays of different shapes when performing arithmetic operations.
Ques 2. How to perform element-wise multiplication of two NumPy arrays?
import numpy as npnarr1 = np.array([1, 2, 3])narr2 = np.array([4, 5, 6])nresult = arr1 * arr2
Ques 3. Explain the purpose of np.random.seed() in NumPy.
np.random.seed() is used to initialize the random number generator in NumPy, ensuring reproducibility of random results.
Ques 4. Explain the concept of a NumPy universal function (ufunc).
A ufunc in NumPy is a flexible function that operates element-wise on NumPy arrays, supporting broadcasting.
Ques 5. How to concatenate two NumPy arrays vertically?
You can use 'np.vstack()' or 'np.concatenate()' with 'axis=0'.
Ques 6. What is the purpose of 'np.ravel()' in NumPy?
'np.ravel()' returns a flattened 1D array from a multi-dimensional array.
Ques 7. Explain the purpose of 'np.concatenate()' in NumPy.
'np.concatenate()' joins a sequence of arrays along an existing axis.
Ques 8. How to perform matrix multiplication in NumPy?
You can use 'np.matmul()' or the '@' operator. For example, 'result = np.matmul(arr1, arr2)' or 'result = arr1 @ arr2'.
Most helpful rated by users:
Related interview subjects
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 |
Flask interview questions and answers - Total 40 questions |
PySpark interview questions and answers - Total 30 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 |
NumPy interview questions and answers - Total 30 questions |
Python interview questions and answers - Total 106 questions |