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 - Creating Arrays
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}
Barray([1, 2, 3])
Cnp.list([1, 2, 3])
Dnp.array([1, 2, 3])
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct NumPy array syntax

    The function to create arrays is np.array() with parentheses and a list inside.
  2. Step 2: Check each option

    np.array([1, 2, 3]) uses correct syntax. array([1, 2, 3]) misses np.. np.list([1, 2, 3]) uses wrong function. np.array{1, 2, 3} uses braces instead of parentheses.
  3. Final Answer:

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

    Correct function and syntax = A [OK]
Quick Trick: Use np.array() with parentheses and list inside [OK]
Common Mistakes:
  • Omitting np. prefix
  • Using curly braces instead of parentheses
  • Using wrong function names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes