ProgrammingModerateGATE CS · Product-company placement

What is printed?

What is printed?
s = "programming"
print(s[-3:-8:-2], s[100:], s[-100:3])
  1. A. mmr pro
  2. B. imr pro
  3. C. rmi pro
  4. D. imr prog

Correct answer: B. imr pro

s[-3:-8:-2] starts at index 8 ('i') and takes indices 8, 6, 4 = 'i', 'm', 'r', stopping before index 3. Out-of-range slice bounds are clipped silently, so s[100:] is '' and s[-100:3] is 'pro'.

More Python Programming questions

Exams that ask this topic