Bird
0
0

Given a Python list data = [4, 5, 6], which of the following is the correct way to convert it into a NumPy array?

easy📝 Syntax Q3 of 15
NumPy - Fundamentals
Given a Python list data = [4, 5, 6], which of the following is the correct way to convert it into a NumPy array?
Anp.array(data)
Bnumpy.list_to_array(data)
Cnp.convert(data)
Darray(data)
Step-by-Step Solution
Solution:
  1. Step 1: Identify NumPy array creation function

    The standard function to create a NumPy array from a list is np.array().
  2. Step 2: Check other options

    Functions like numpy.list_to_array or np.convert do not exist.
  3. Final Answer:

    np.array(data) -> Option A
  4. Quick Check:

    Use np.array() to convert lists to arrays [OK]
Quick Trick: Use np.array() to convert lists to arrays [OK]
Common Mistakes:
  • Using non-existent functions like np.convert()
  • Trying to call array() without np prefix
  • Assuming lists have a built-in method to convert to arrays

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes