Interview Questions and Answers
Freshers / Beginner level questions & answers
Ques 1. What is NumPy?
NumPy is a library for the Python programming language, adding support for large, multi-dimensional arrays and matrices, along with mathematical functions to operate on these arrays.
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Ques 2. How to install NumPy?
You can install NumPy using the command 'pip install numpy'.
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Ques 3. Create a NumPy array from a Python list.
import numpy as npnmy_list = [1, 2, 3]narr = np.array(my_list)
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Ques 4. How to find the dimension of a NumPy array?
You can use the attribute 'ndim'. For example, if 'arr' is your array, use 'arr.ndim'.
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Ques 5. What is the difference between 'np.zeros()' and 'np.ones()' in NumPy?
'np.zeros()' creates an array filled with zeros, while 'np.ones()' creates an array filled with ones.
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Ques 6. How to access elements from a 2D NumPy array?
You can use indices. For example, 'arr[1, 2]' accesses the element in the second row and third column of 'arr'.
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Ques 7. How to find the shape of a NumPy array?
You can use the attribute 'shape'. For example, 'arr.shape' returns the shape of 'arr'.
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Ques 8. What is the purpose of 'np.eye()' in NumPy?
'np.eye()' creates an identity matrix with ones on the main diagonal and zeros elsewhere.
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Ques 9. How to perform element-wise addition of two NumPy arrays?
import numpy as npnarr1 = np.array([1, 2, 3])narr2 = np.array([4, 5, 6])nresult = arr1 + arr2
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Ques 10. What is the purpose of 'np.arange()' in NumPy?
'np.arange()' creates an array with regularly spaced values within a specified range.
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Ques 11. How to find the mean of a NumPy array?
You can use 'np.mean()'. For example, 'mean_value = np.mean(arr)'.
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Intermediate / 1 to 5 years experienced level questions & answers
Ques 12. Explain broadcasting in NumPy.
Broadcasting is a powerful mechanism that allows NumPy to work with arrays of different shapes when performing arithmetic operations.
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Ques 13. 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 14. 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 15. 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 16. How to concatenate two NumPy arrays vertically?
You can use 'np.vstack()' or 'np.concatenate()' with 'axis=0'.
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Ques 17. What is the purpose of 'np.ravel()' in NumPy?
'np.ravel()' returns a flattened 1D array from a multi-dimensional array.
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Ques 18. Explain the purpose of 'np.concatenate()' in NumPy.
'np.concatenate()' joins a sequence of arrays along an existing axis.
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Ques 19. 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'.
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Experienced / Expert level questions & answers
Ques 20. 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 21. 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 22. Create a diagonal matrix using NumPy.
import numpy as npnarr = np.diag([1, 2, 3])
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Ques 23. 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 24. 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 25. 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 26. What is the purpose of 'np.where()' in NumPy?
'np.where()' returns the indices of elements that satisfy a given condition.
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Ques 27. Explain the use of 'np.linalg.inv()' in NumPy.
'np.linalg.inv()' computes the (multiplicative) inverse of a matrix.
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Ques 28. What is the purpose of 'np.percentile()' in NumPy?
'np.percentile()' calculates the nth percentile of a dataset.
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Ques 29. Explain the use of 'np.unique()' in NumPy.
'np.unique()' returns the unique elements of an array.
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Ques 30. How to transpose a NumPy array?
You can use 'arr.T'. For example, 'transposed_arr = arr.T'.
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
Most helpful rated by users:
- How to install NumPy?
- Create a NumPy array from a Python list.
- What is NumPy?
- What is the difference between 'np.zeros()' and 'np.ones()' in NumPy?
- What is the purpose of 'np.eye()' in NumPy?
Related interview subjects
| 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 |
| Python Pandas interview questions and answers - Total 48 questions |
| Django interview questions and answers - Total 50 questions |
| Python Matplotlib interview questions and answers - Total 30 questions |