CARVIEW |
Array Operations in NumPy
This quiz consists of 10 questions, starting with basic array operations and progressing to advanced concepts. Each question includes the correct answer and justification.
Question 2
What will be the output of the following code?
import numpy as np
arr1 = np.array([1, 2, 3])
arr2 = np.array([4, 5, 6])
result = arr1 * arr2
print(result)
Error
[5, 7, 9]
[1, 2, 3, 4, 5, 6]
[4, 10, 18]
Question 3
Which NumPy function is used to perform matrix multiplication?
np.matmul()
np.multiply()
np.dot()
np.add()
Question 4
What will be the output of the following code?
import numpy as np
arr = np.array([10, 20, 30])
result = arr + 5
print(result)
[5, 15, 25]
[50, 100, 150]
Error
[15, 25, 35]
Question 5
What will be the output of this code?
import numpy as np
arr = np.array([1, 2, 3, 4])
result = np.sum(arr)
print(result)
4
[1, 2, 3, 4]
10
Error
Question 6
Which of the following functions is used to compute the cumulative sum of array elements?
np.sum()
np.cumsum()
np.add()
np.prod()
Question 7
What does the np.mean() function compute?
Sum of array elements
Product of array elements
Average of array elements
Median of array elements
Question 8
What will be the output of this code?
import numpy as np
arr = np.array([[1, 2], [3, 4]])
result = np.sum(arr, axis=0)
print(result)
[4, 8]
[3, 7]
[4, 6]
Error
Question 9
Which function would you use to calculate the standard deviation of an array?
np.var()
np.std()
np.mean()
np.median()
Question 10
What will be the output of this code?
import numpy as np
arr1 = np.array([1, 2])
arr2 = np.array([3, 4])
result = np.dot(arr1, arr2)
print(result)
10
7
[3, 8]
Error
There are 10 questions to complete.