Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.

Unit 7 MCQs Operations on NumPy arrays

ECAP776 60 questions. Pick an option to check it.

Read the notes Subjective questions

0 of 60 answered 0 right 0 wrong , 60 left

  1. Question 1 of 60 Array manipulation Easy

    Which NumPy method changes the shape of an array without changing its data?

  2. Question 2 of 60 Array manipulation Easy

    Which attribute returns the dimensions of a NumPy array?

  3. Question 3 of 60 Array manipulation Easy

    What does the flatten() method return?

  4. Question 4 of 60 Array manipulation Easy

    Which NumPy function joins arrays along an existing axis?

  5. Question 5 of 60 Array manipulation Easy

    What does arr.T represent for a two-dimensional NumPy array?

  6. Question 6 of 60 Array manipulation Easy

    Which NumPy function divides an array into multiple subarrays?

  7. Question 7 of 60 Array manipulation Easy

    What is the shape of np.array([1, 2, 3, 4]).reshape(2, 2)?

  8. Question 8 of 60 Broadcasting Easy

    What is broadcasting in NumPy?

  9. Question 9 of 60 Broadcasting Easy

    What happens when the scalar 5 is added to a NumPy array?

  10. Question 10 of 60 Broadcasting Easy

    Which pair of shapes is compatible for broadcasting?

  11. Question 11 of 60 Broadcasting Easy

    When comparing dimensions during broadcasting, which value is compatible with any dimension size?

  12. Question 12 of 60 Broadcasting Easy

    What is the result of np.array([1, 2, 3]) + 2?

  13. Question 13 of 60 Broadcasting Easy

    For broadcasting, NumPy compares array shapes starting from which side?

  14. Question 14 of 60 Broadcasting Easy

    What is a key benefit of NumPy broadcasting?

  15. Question 15 of 60 Binary operators Easy

    Which operator performs element-wise addition on NumPy arrays?

  16. Question 16 of 60 Binary operators Easy

    What is the result of np.array([2, 4]) * np.array([3, 5])?

  17. Question 17 of 60 Binary operators Easy

    Which operator performs element-wise exponentiation in NumPy?

  18. Question 18 of 60 Binary operators Easy

    Which operator performs matrix multiplication between two suitable NumPy arrays?

  19. Question 19 of 60 Binary operators Easy

    What does the % operator calculate element-wise?

  20. Question 20 of 60 Binary operators Easy

    What is the result of np.array([5, 8]) > np.array([3, 10])?

  21. Question 21 of 60 Array manipulation Medium

    What is printed by the following code?

    a = np.arange(6)

    b = a.reshape(2, 3)

    b[0, 0] = 99

    print(a[0])

  22. Question 22 of 60 Array manipulation Medium

    Given a = np.arange(24).reshape(2, 3, 4) and b = np.transpose(a, (1, 0, 2)), what are b.shape and b[2, 1, 3]?

  23. Question 23 of 60 Array manipulation Medium

    What is the result of np.concatenate((x, y), axis=1) when x = np.ones((2, 2), dtype=int) and y = np.zeros((2, 1), dtype=int)?

  24. Question 24 of 60 Array manipulation Medium

    Given x = np.array([1, 2]) and y = np.array([3, 4]), what does np.stack((x, y), axis=1) produce?

  25. Question 25 of 60 Array manipulation Medium

    What are the lengths of the arrays returned by np.array_split(np.arange(10), 3)?

  26. Question 26 of 60 Array manipulation Medium

    Given a = np.array([[1, 2, 3], [4, 5, 6]]), what does np.flip(a, axis=1) return?

  27. Question 27 of 60 Array manipulation Medium

    After running a = np.array([[1, 2], [3, 4]]), b = a.flatten(), and b[0] = 9, what is a?

  28. Question 28 of 60 Broadcasting Medium

    What is the shape of the result when arrays with shapes (3, 1) and (1, 4) are added?

  29. Question 29 of 60 Broadcasting Medium

    What is the result of np.array([[1, 2, 3], [4, 5, 6]]) + np.array([10, 20, 30])?

  30. Question 30 of 60 Broadcasting Medium

    An array a has shape (2, 3, 4) and an array b has shape (3, 1). What is the shape of a + b?

  31. Question 31 of 60 Broadcasting Medium

    What happens when an array of shape (4, 3) is added to an array of shape (4,)?

  32. Question 32 of 60 Broadcasting Medium

    For a = np.array([[1., 3.], [2., 6.]]), which expression subtracts each row's mean from that row using broadcasting?

  33. Question 33 of 60 Broadcasting Medium

    If a = np.array([1, 2, 3]) and b = np.array([10, 20]), what is the shape of a[:, np.newaxis] * b?

  34. Question 34 of 60 Broadcasting Medium

    What is the final value of a after a = np.zeros((2, 3), dtype=int) followed by a[:] = np.array([1, 2, 3])?

  35. Question 35 of 60 Binary operators Medium

    Given a = np.array([1, 2, 3]) and b = np.array([4, 5, 6]), what does a * b return?

  36. Question 36 of 60 Binary operators Medium

    What is the result of np.array([[1, 2], [3, 4]]) @ np.array([5, 6])?

  37. Question 37 of 60 Binary operators Medium

    For a = np.array([0, 1, 2, 3, 4]), what does (a > 1) & (a < 4) return?

  38. Question 38 of 60 Binary operators Medium

    What is the result of np.array([-7, 7]) // 3?

  39. Question 39 of 60 Binary operators Medium

    What does np.array([5, 6, 7]) ^ np.array([3, 3, 3]) produce?

  40. Question 40 of 60 Binary operators Medium

    For a = np.array([1, 2, 3, 4]), what does (a % 2 == 0) | (a > 3) return?

  41. Question 41 of 60 Array manipulation Hard

    What is printed by the following code?

    a = np.arange(12).reshape(3, 4)

    b = a.T

    c = b.reshape(2, 6)

    c[0, 1] = -1

    print(a[1, 0], np.shares_memory(a, c))

  42. Question 42 of 60 Array manipulation Hard

    What is the value of b[-1] after this code?

    a = np.array([1, 2, 3, 4])

    b = np.resize(a, (3, 3))

  43. Question 43 of 60 Array manipulation Hard

    If x.shape is (2, 3, 4, 5), what is the shape of np.moveaxis(x, (0, 3), (2, 0))?

  44. Question 44 of 60 Array manipulation Hard

    Which sequence of lists is produced by [part.tolist() for part in np.array_split(np.arange(10), 3)]?

  45. Question 45 of 60 Array manipulation Hard

    What is the final value of a?

    a = np.zeros(4, dtype=int)

    idx = np.array([0, 0, 2])

    a[idx] += 1

  46. Question 46 of 60 Array manipulation Hard

    What happens when np.empty((0, 3)).reshape(-1, 0) is evaluated?

  47. Question 47 of 60 Array manipulation Hard

    Given two arrays a and b, each with shape (2, 3), what is the shape of np.stack((a, b), axis=-1)?

  48. Question 48 of 60 Broadcasting Hard

    What is the result shape of adding arrays with shapes (2, 1, 3, 1) and (1, 4, 1, 5)?

  49. Question 49 of 60 Broadcasting Hard

    Which pair of shapes cannot be broadcast together under NumPy's standard broadcasting rules?

  50. Question 50 of 60 Broadcasting Hard

    What is the value of a[1, :, 2] after this code?

    a = np.zeros((2, 3, 4), dtype=int)

    v = np.arange(3).reshape(3, 1)

    a[:] = v

  51. Question 51 of 60 Broadcasting Hard

    What happens in the following code?

    a = np.array([1, 2, 3])

    b = np.broadcast_to(a, (4, 3))

    b[0, 0] = 9

  52. Question 52 of 60 Broadcasting Hard

    What is the shape of the result when arrays with shapes (0, 3, 1) and (1, 1, 4) are added?

  53. Question 53 of 60 Broadcasting Hard

    What does the following expression return?

    x = np.array([[1], [2]])

    y = np.array([10, 20, 30])

    c = np.array([[True, False, True], [False, True, False]])

    np.where(c, x, y)

  54. Question 54 of 60 Broadcasting Hard

    For matrix multiplication, A has shape (2, 1, 3, 4) and B has shape (5, 4, 6). What is the shape of A @ B?

  55. Question 55 of 60 Binary operators Hard

    What are the values of a // b and a % b?

    a = np.array([-7, 7])

    b = np.array([3, -3])

  56. Question 56 of 60 Binary operators Hard

    Assuming standard NumPy fixed-width integer arithmetic, what is produced by this expression?

    np.array([1, 2, 3], dtype=np.uint8) - np.array([2], dtype=np.uint8)

  57. Question 57 of 60 Binary operators Hard

    What happens when the following expression is evaluated?

    a = np.array([0, 2, 4])

    a > 1 & a < 4

  58. Question 58 of 60 Binary operators Hard

    What values are printed by this code?

    A = np.array([[1, 2], [3, 4]])

    b = np.array([5, 6])

    print(A @ b, b @ A)

  59. Question 59 of 60 Binary operators Hard

    What happens when np.array([2, 4], dtype=int) ** -1 is evaluated?

  60. Question 60 of 60 Binary operators Hard

    What is the result of a ^ b & a for the arrays below?

    a = np.array([True, False, True])

    b = np.array([True, True, False])

That's unit 7

Answer a few questions and your score shows up here.