What does 'ufunc' stand for in NumPy?
A
User Function B
Universal Function C
Uniform Function D
Utility Function
Analysis & Theory
`ufunc` stands for Universal Function — functions that operate element-wise on arrays.
Which of the following is a ufunc in NumPy?
A
np.append() B
np.insert() C
np.add() D
np.array()
Analysis & Theory
`np.add()` is a ufunc; it performs fast element-wise addition on arrays.
Which ufunc can be used to compute square roots of all elements in an array?
A
np.pow() B
np.sqrt() C
np.square() D
np.exp()
Analysis & Theory
`np.sqrt()` is a universal function used to compute square roots element-wise.
What does `np.add([1, 2], [3, 4])` return?
A
[4, 6] B
[1, 2, 3, 4] C
10 D
[3, 6]
Analysis & Theory
`np.add()` adds arrays element-wise: [1+3, 2+4] = [4, 6].
Which ufunc is used to calculate exponential values (e^x)?
A
np.power() B
np.exp() C
np.exponential() D
np.expval()
Analysis & Theory
`np.exp()` calculates the exponential of all array elements.
Which of the following best describes ufuncs?
A
They operate on lists only B
They are always slower than Python loops C
They operate element-wise and support broadcasting D
They can only handle integers
Analysis & Theory
Ufuncs operate element-wise, support broadcasting, and are optimized for performance.
What does `np.multiply([2, 3], [4, 5])` return?
A
[6, 8] B
[8, 15] C
[2, 3, 4, 5] D
[10, 12]
Analysis & Theory
Element-wise multiplication: [2×4, 3×5] = [8, 15].
Which function is NOT a ufunc in NumPy?
A
np.subtract() B
np.divide() C
np.append() D
np.mod()
Analysis & Theory
`np.append()` is not a ufunc; it performs array concatenation, not element-wise computation.
What is broadcasting in the context of NumPy ufuncs?
A
Streaming arrays over a network B
Operating on arrays with different shapes by following specific rules C
Printing arrays D
Sorting arrays automatically
Analysis & Theory
Broadcasting allows operations on arrays of different shapes if they are compatible.
Which ufunc returns the remainder of division element-wise?
A
np.remainder() B
np.div() C
np.rest() D
np.leftover()
Analysis & Theory
`np.remainder()` returns the element-wise remainder of division.