NumPy Interview Questions

Crack your next data science interview with confidence!

Companies

Set 1

Q1–Q10: Core Basics & Array Creation

  1. What is NumPy and how is it different from Python lists?

  2. How do you create 1D, 2D, and 3D arrays in NumPy?

  3. Explain the difference between np.array(), np.asarray(), and np.copy().

  4. How do you create an array of zeros, ones, and an identity matrix in NumPy?

  5. What does np.arange() do, and how is it different from np.linspace()?

  6. How can you check the shape, size, and datatype of a NumPy array?

  7. What’s the default datatype of NumPy arrays and how do you explicitly set it?

  8. How do you convert a Python list or tuple into a NumPy array?

  9. How do you generate random numbers with NumPy? Explain np.random.rand() vs np.random.randn().

  10. How can you reshape a NumPy array? What rules must be followed?

Q11–Q20: Indexing & Slicing

  1. How do you access a specific element in a multi-dimensional array?

  2. How does slicing work in 1D, 2D arrays? Provide examples.

  3. What is the difference between slicing a NumPy array and slicing a list?

  4. Explain the difference between a view and a copy in NumPy slicing.

  5. What happens when you slice and modify a NumPy array? Does the original change?

  6. How can you use boolean indexing to filter data in a NumPy array?

  7. How do you select all elements greater than a certain value from an array?

  8. How to use np.where() to find indices of specific conditions?

  9. How can you find unique values in an array and count their frequency?

  10. What does the .flat, .ravel(), and .flatten() function do?

Q21–Q30: Basic Operations & Statistics

 

  1. How do you add, subtract, multiply, and divide arrays in NumPy?

  2. What’s the difference between element-wise multiplication and matrix multiplication?

  3. How to calculate mean, median, and standard deviation in a NumPy array?

  4. How do you perform broadcasting in NumPy? Provide an example.

  5. Explain the concept of axis in NumPy operations like sum() or mean().

  6. What does np.dot() do? How is it different from np.matmul()?

  7. How do you sort a NumPy array along rows and columns?

  8. How can you find the minimum and maximum value along an axis?

  9. What’s the use of np.argsort() and np.argmin()?

  10. How do you normalize a NumPy array?