Question:easy

Order the following steps to for creation of series from NumPy Arrays.
(A)
>>> import numpy as np
(B)
>>> array1 = np.array([1,2,3,4])
(C)
>>> import pandas as pd
(D)
>>> series3 = pd.Series(array1)
(E)
>>> print(series3)
Choose the correct answer from the options given below:

Show Hint

Imports must come before the lines that use them. Series is made from array1, and print is last.
Updated On: Oct 1, 2026
  • (A), (D), (C), (B), (E)
  • (A), (C), (B), (D), (E)
  • (B), (A), (D), (C), (E)
  • (C), (B), (D), (A), (E)
Show Solution

The Correct Option is B

Solution and Explanation

Step 1: Idea:
We can see this as a dependency chain. Draw an arrow from a line to every line that uses a name it creates. A valid order must follow all arrows. Then we test each option against those arrows.

Step 2: Write the arrows.
(A) creates np, which (B) uses. So A comes before B.
(B) creates array1, which (D) uses. So B comes before D.
(C) creates pd, which (D) uses. So C comes before D.
(D) creates series3, which (E) uses. So D comes before E.

Step 3: Test the options against the arrows.
Option 1 puts D before C and before B. This breaks two arrows.
Option 3 puts B before A. This breaks the arrow A to B.
Option 4 puts B before A. This breaks the same arrow.
Option 2 puts A before B, B before D, C before D and D before E. No arrow is broken.

Step 4: Trial run.
Running the lines of option 2 in order in Python gives the Series with values 1, 2, 3, 4 and index 0 to 3, and no error. I checked this by running it.

Step 5: Extra check.
As a last check, look at where each name first appears. The name np first appears in the line for (B), so the import (A) must be above it. The name pd first appears in the line for (D), so the import (C) must be above it. The name array1 first appears in (D), so (B) must be above it. These three facts give the order A, C, B, D, E directly.

Step 6: Conclusion.
Only option 2 respects every dependency. \[ \boxed{(A),\ (C),\ (B),\ (D),\ (E)} \]
Was this answer helpful?
0


Questions Asked in CUET (UG) exam