Question:medium

What will be the output of the following code?
>>> seriesCapCntry = pd.Series(['NewDelhi', 'WashingtonDC', 'London', 'Paris'], index=['India', 'USA', 'UK', 'France'])
>>> seriesCapCntry[1:3]

Show Hint

Remember: positional slicing [1:3] in Python is exclusive of the end index (stops at 2).
However, label-based slicing ['USA':'UK'] is inclusive of the end label!
Paying attention to the type of indices in slices prevents silly mistakes.
Updated On: Jun 11, 2026
  • 1
  • 2
  • 3
  • 4
Show Solution

The Correct Option is A

Solution and Explanation


Step 1: Understanding the Question:

The question asks for the resulting output when slicing a Pandas Series object using positional integer index slices.

Step 2: Key Formula or Approach:

In Pandas, when slicing a Series using positional indexing (series[start:stop]), the slice is inclusive of the start index and exclusive of the stop index.
The indices correspond to positions:
- Position 0: 'India' $\rightarrow$ 'NewDelhi'
- Position 1: 'USA' $\rightarrow$ 'WashingtonDC'
- Position 2: 'UK' $\rightarrow$ 'London'
- Position 3: 'France' $\rightarrow$ 'Paris'

Step 3: Detailed Explanation:

The slice expression is seriesCapCntry[1:3].
This extracts elements starting at position 1 up to (but not including) position 3.
The positions selected are 1 and 2.
At position 1, the index label is 'USA' and the value is 'WashingtonDC'.
At position 2, the index label is 'UK' and the value is 'London'.
Pandas displays Series slices with both their index labels and their associated values.
Thus, the printed output will show:
USA WashingtonDC
UK London
This matches option (A).

Step 4: Final Answer:

The correct output of the positional slicing is option (A).
Was this answer helpful?
0


Questions Asked in CUET (UG) exam