Bird
0
0

Which of the following is the correct way to create a 1-dimensional NumPy array with elements 1, 2, and 3?

easy📝 Syntax Q12 of 15
SciPy - Basics and Scientific Computing
Which of the following is the correct way to create a 1-dimensional NumPy array with elements 1, 2, and 3?
Anp.array(1, 2, 3)
Bnp.array([1, 2, 3])
Cnp.array{1, 2, 3}
Dnp.array([1; 2; 3])
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct syntax for np.array

    NumPy arrays are created by passing a list inside parentheses: np.array([elements]).
  2. Step 2: Check each option

    np.array([1, 2, 3]) uses correct syntax with square brackets inside parentheses. Others have syntax errors.
  3. Final Answer:

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

    np.array needs a list inside parentheses [OK]
Quick Trick: Use square brackets inside parentheses to create arrays [OK]
Common Mistakes:
MISTAKES
  • Omitting square brackets around elements
  • Using curly braces instead of square brackets
  • Separating elements with semicolons inside list

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes