Skip to main contentSkip to solution

Consider the following statement:

Country = pd.Series(['India','Nepal','Germany','Poland','USA'])

What will the following command result in?

print (Country [: : -1])

Solution

✅ Correct Option: 3

The slice [::-1] uses a step of -1, so it reads the Series from the last element to the first. The elements come out in reverse order, and each keeps its original index label. The output is therefore USA (4), Poland (3), Germany (2), Nepal (1), India (0), with dtype object.

Position readIndex labelValue
1st4USA
2nd3Poland
3rd2Germany
4th1Nepal
5th0India

Option 1: the values are reversed, but the index is wrongly renumbered from 0 and India is missing.

Option 2: this is the original Series, which [::] or [:] would print.

Option 4: it drops USA and shows the original labels attached to the wrong values.

Slicing a Series reverses the order but never resets the index labels; use reset_index(drop=True) if you want fresh labels.

Keyboard Shortcuts

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