NumPy Interview Test – Top 20 Questions
Q1 (2 Marks)
Why is NumPy faster than Python lists? Explain vectorization.
Q2 (2 Marks)
Differentiate between [Link]() and [Link]() with examples.
Q3 (2 Marks)
What is broadcasting? Explain the broadcasting rules with an example.
Q4 (2 Marks)
Differentiate between flatten() and ravel(). Which one is memory efficient?
Q5 (2 Marks)
Given an array, find shape, size, ndim and dtype.
Q6 (2 Marks)
Explain axis=0 and axis=1 with examples.
Q7 (2 Marks)
What is Boolean indexing? Write code to display values greater than 50.
Q8 (2 Marks)
What is fancy indexing? Explain with an example.
Q9 (2 Marks)
What is the purpose of [Link]()?
Q10 (2 Marks)
Write code to generate a 5×5 matrix of random integers between 1 and 100.
Q11 (2 Marks)
Create an array from 1 to 20 and reshape it into a 4×5 matrix.
Q12 (2 Marks)
Find maximum, minimum, mean and standard deviation of an array.
Q13 (2 Marks)
Differentiate between [Link](), [Link]() and [Link]().
Q14 (2 Marks)
Write code to sort an array and find unique values.
Q15 (2 Marks)
What is the difference between views and copies in NumPy?
Q16 (2 Marks)
Explain [Link]() with a suitable example.
Q17 (2 Marks)
Perform matrix multiplication of two 2×2 matrices.
Q18 (2 Marks)
Find transpose, determinant and inverse of a matrix.
Q19 (2 Marks)
Differentiate between * operator and [Link]().
Q20 (5 Marks)
Scenario: A dataset contains one million values. How would NumPy improve performance
compared to Python lists? Explain with examples.