Bird
0
0

Which of the following is the correct syntax to create a NumPy array from a Python list named data?

easy📝 Syntax Q3 of 15
NumPy - Fundamentals
Which of the following is the correct syntax to create a NumPy array from a Python list named data?
Aarray(data)
Bnp.array(data)
Cnp.array[data]
Dnumpy.array[data]
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct NumPy array creation syntax

    The correct syntax uses parentheses with np.array and the list inside.
  2. Step 2: Identify incorrect syntax

    Square brackets are invalid for function calls; 'numpy' must be imported as 'np' to use np.array.
  3. Final Answer:

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

    Array creation syntax = np.array(data) [OK]
Quick Trick: Use parentheses, not square brackets, to create arrays [OK]
Common Mistakes:
  • Using square brackets instead of parentheses
  • Using 'numpy' without import alias
  • Mixing syntax styles

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes