Bird
0
0

Which of the following is the correct way to create a NumPy array from a Python list [1, 2, 3]?

easy📝 Syntax Q12 of 15
NumPy - Fundamentals
Which of the following is the correct way to create a NumPy array from a Python list [1, 2, 3]?
Anp.array([1, 2, 3])
Bnp.list([1, 2, 3])
Carray([1, 2, 3])
Dnp.create_array(1, 2, 3)
Step-by-Step Solution
Solution:
  1. Step 1: Recall NumPy array creation syntax

    The function to create arrays is np.array() which takes a list as input.
  2. Step 2: Check each option

    Only np.array([1, 2, 3]) uses correct function and syntax; others are invalid or undefined.
  3. Final Answer:

    np.array([1, 2, 3]) -> Option A
  4. Quick Check:

    Use np.array() to create arrays [OK]
Quick Trick: Use np.array() to convert lists [OK]
Common Mistakes:
  • Using undefined functions like np.list()
  • Omitting np prefix
  • Passing multiple arguments instead of a list

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes