Skip to main contentSkip to solution

Seriescntry = pd.Series(['India', 'Canada', 'Brazil', 'Australia', 'USA', China', 'Russia']) is created. If slicing is performed using Seriescntry = Seriescntry[3: 5], then what will be the output?

Solution

✅ Correct Option: 1

Slicing a Series with [start:stop] uses position, starting from 0, and the stop position is excluded. So [3:5] returns positions 3 and 4.

Position0123456
ValueIndiaCanadaBrazilAustraliaUSAChinaRussia

The result keeps the original index labels:

3 Australia

4 USA


Option 2: includes position 5, but the stop value is excluded in positional slicing. Only .loc[3:5] with labels would include 5.

Options 3 and 4: start at position 2 (Brazil), but the slice starts at position 3.

Keyboard Shortcuts

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