Skip to main contentSkip to solution

Arrange the following statements in proper sequence:-

(A) series1 = pd.Series(array1)

(B) import pandas as pd

(C) array1 = np. array ([1, 2, 3, 4, 5])

(D) import numpy as np

Solution

✅ Correct Option: 1

(B) import pandas as pd loads the pandas library, so pd is defined.

(D) import numpy as np loads NumPy, so np is defined.

(C) array1 = np.array([1, 2, 3, 4, 5]) needs np, so it comes after the imports.

(A) series1 = pd.Series(array1) needs both pd and array1, so it comes last.


Options 2 and 3: (A) uses array1 before it has been created, which gives a NameError.

Option 4: (C) uses np before NumPy is imported, which gives a NameError.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question