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 6 MCQs Introduction to NumPy

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 Arrays vs lists Easy

    Which Python library provides the ndarray data type?

  2. Question 2 of 60 Arrays vs lists Easy

    What does multiplying np.array([1, 2, 3]) by 2 produce?

  3. Question 3 of 60 Arrays vs lists Easy

    What does multiplying the Python list [1, 2] by 2 produce?

  4. Question 4 of 60 Arrays vs lists Easy

    Which statement about NumPy arrays is generally true?

  5. Question 5 of 60 Arrays vs lists Easy

    Which attribute gives the dimensions of a NumPy array?

  6. Question 6 of 60 Array creation routines Easy

    Which function creates a NumPy array filled with zeros?

  7. Question 7 of 60 Array creation routines Easy

    What does np.ones(4) create?

  8. Question 8 of 60 Array creation routines Easy

    Which function creates evenly spaced values within a specified interval using a requested number of values?

  9. Question 9 of 60 Array creation routines Easy

    What values are produced by np.arange(1, 5)?

  10. Question 10 of 60 Array creation routines Easy

    Which expression creates a array filled with zeros?

  11. Question 11 of 60 Arrays from existing data Easy

    Which expression converts the list [2, 4, 6] into a NumPy array?

  12. Question 12 of 60 Arrays from existing data Easy

    Which existing Python object can be passed directly to np.array()?

  13. Question 13 of 60 Arrays from existing data Easy

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

  14. Question 14 of 60 Arrays from existing data Easy

    Which NumPy function can convert existing data to an array while avoiding a copy when possible?

  15. Question 15 of 60 Arrays from existing data Easy

    What is the number of dimensions of np.array([5, 10, 15])?

  16. Question 16 of 60 Indexing and slicing Easy

    Given a = np.array([10, 20, 30]), what is the value of a[0]?

  17. Question 17 of 60 Indexing and slicing Easy

    Given a = np.array([10, 20, 30, 40]), what does a[1:3] return?

  18. Question 18 of 60 Indexing and slicing Easy

    Which index selects the last element of a one-dimensional NumPy array?

  19. Question 19 of 60 Indexing and slicing Easy

    Given a = np.array([[1, 2], [3, 4]]), what is the value of a[1, 0]?

  20. Question 20 of 60 Indexing and slicing Easy

    Given a = np.array([2, 4, 6, 8]), what does a[::2] return?

  21. Question 21 of 60 Arrays vs lists Medium

    What is the output of (a + a).tolist(), b + b when a = np.array([1, 2]) and b = [1, 2]?

  22. Question 22 of 60 Arrays vs lists Medium

    Given a = np.array([2, 3]) and b = [2, 3], what are the results of a * 2 and b * 2?

  23. Question 23 of 60 Arrays vs lists Medium

    What does np.array([1, 2]) + [10, 20] produce?

  24. Question 24 of 60 Arrays vs lists Medium

    What is the result of np.array([1, 2.5, 3]).dtype on a typical NumPy installation?

  25. Question 25 of 60 Arrays vs lists Medium

    Which statement correctly compares a NumPy array with a Python list?

  26. Question 26 of 60 Array creation routines Medium

    What array is created by np.arange(2, 11, 3)?

  27. Question 27 of 60 Array creation routines Medium

    Which result is produced by np.linspace(0, 1, 5)?

  28. Question 28 of 60 Array creation routines Medium

    After a = np.zeros((2, 3)), what are a.shape and a.size?

  29. Question 29 of 60 Array creation routines Medium

    Which expression creates a integer array in which every element is 7?

  30. Question 30 of 60 Array creation routines Medium

    How many elements equal 1 in the array created by np.eye(3, k=1)?

  31. Question 31 of 60 Arrays from existing data Medium

    What are the shape and number of dimensions of np.array([[1, 2], [3, 4]])?

  32. Question 32 of 60 Arrays from existing data Medium

    Consider a = np.array([1, 2, 3]), b = np.asarray(a), and then b[0] = 9. What is a afterward?

  33. Question 33 of 60 Arrays from existing data Medium

    Consider a = np.array([1, 2, 3]), b = np.array(a, copy=True), and then b[1] = 8. What is a afterward?

  34. Question 34 of 60 Arrays from existing data Medium

    What does np.fromiter((x * x for x in range(4)), dtype=int) create?

  35. Question 35 of 60 Arrays from existing data Medium

    What does np.fromstring("2 4 6 8", dtype=int, sep=" ") produce?

  36. Question 36 of 60 Indexing and slicing Medium

    Let a = np.arange(12).reshape(3, 4). What does a[1:, ::2] return?

  37. Question 37 of 60 Indexing and slicing Medium

    Given a = np.array([[10, 20, 30], [40, 50, 60]]), what is a[-1, -2]?

  38. Question 38 of 60 Indexing and slicing Medium

    Consider a = np.array([1, 2, 3, 4]), b = a[1:3], and then b[0] = 9. What is a afterward?

  39. Question 39 of 60 Indexing and slicing Medium

    What does a[(a > 2) & (a < 6)] return when a = np.array([1, 3, 5, 7])?

  40. Question 40 of 60 Indexing and slicing Medium

    Let a = np.arange(9).reshape(3, 3). What does a[[2, 0], [1, 2]] return?

  41. Question 41 of 60 Arrays vs lists Hard

    What are the final values of a and L?

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

    v = a[1:3]

    L = [1, 2, 3, 4]

    s = L[1:3]

    v[:] = 0

    s[:] = [0, 0]

  42. Question 42 of 60 Arrays vs lists Hard

    Given a = np.array([1, 2, 3]) and L = [1, 2, 3], what are the values of a * 2 and L * 2?

  43. Question 43 of 60 Arrays vs lists Hard

    What are the final contents of a and L?

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

    L = [1, 2, 3]

    a[0] = 2.9

    L[0] = 2.9

  44. Question 44 of 60 Arrays vs lists Hard

    What do b and M contain after this code?

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

    b = a

    a += 10

    L = [1, 2]

    M = L

    L = L + [10]

  45. Question 45 of 60 Arrays vs lists Hard

    Consider a = np.array([[1], [2]]), b = np.array([10, 20, 30]), L = [[1], [2]], and M = [[10, 20, 30]]. Which pair gives a + b and L + M?

  46. Question 46 of 60 Array creation routines Hard

    What array is created by np.arange(2, 14, 2).reshape(2, 3, order="F")?

  47. Question 47 of 60 Array creation routines Hard

    What does np.linspace(2, 10, num=4, endpoint=False, retstep=True) return?

  48. Question 48 of 60 Array creation routines Hard

    Which array is produced by np.eye(3, 4, k=1, dtype=int)?

  49. Question 49 of 60 Array creation routines Hard

    What are the value and dtype of np.full_like(np.array([1, 2, 3], dtype=np.int16), 3.8)?

  50. Question 50 of 60 Array creation routines Hard

    What is produced by np.fromfunction(lambda i, j: 10 * i + j, (2, 3), dtype=int)?

  51. Question 51 of 60 Arrays from existing data Hard

    What are the final contents of a and c?

    a = np.arange(4)

    b = np.asarray(a)

    c = np.array(a)

    b[0] = 9

    c[1] = 8

  52. Question 52 of 60 Arrays from existing data Hard

    What does a.tolist() return after this code on any machine?

    buf = bytearray([1, 0, 2, 0])

    a = np.frombuffer(buf, dtype="<u2")

    buf[0] = 3

  53. Question 53 of 60 Arrays from existing data Hard

    What are a.tolist() and b.tolist()?

    g = (i * i for i in range(5))

    a = np.fromiter(g, dtype=int, count=3)

    b = np.fromiter(g, dtype=int)

  54. Question 54 of 60 Arrays from existing data Hard

    What are the inferred dtype and values of np.array([1, 2.5, True, 4 + 0j])?

  55. Question 55 of 60 Arrays from existing data Hard

    What are the final contents of x and b?

    x = np.array([[1, 2], [3, 4]], order="F")

    a = np.asarray(x)

    b = np.asarray(x, order="C")

    a[0, 0] = 9

    b[1, 1] = 8

  56. Question 56 of 60 Indexing and slicing Hard

    For a = np.arange(12).reshape(3, 4), what does a[[0, 2], [1, 3]] return?

  57. Question 57 of 60 Indexing and slicing Hard

    Let a = np.arange(24).reshape(2, 3, 4). What is a[:, [2, 0], 1:3]?

  58. Question 58 of 60 Indexing and slicing Hard

    What are the final values of a and b?

    a = np.arange(6).reshape(2, 3)

    b = a[a % 2 == 0]

    b[0] = 99

  59. Question 59 of 60 Indexing and slicing Hard

    What is the final value of a?

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

    a[[0, 0, 1]] += 1

  60. Question 60 of 60 Indexing and slicing Hard

    What is the final value of a?

    a = np.arange(5)

    a[[1, 3]][0] = 99

That's unit 6

Answer a few questions and your score shows up here.