ProgrammingModerateTCS NQT · Accenture

What is printed?

What is printed?
s = 'abc' * 2 + 'd'
print(s[::3], 'bcd' in s, s.index('c', 3))
  1. A. adb True 5
  2. B. aad True 5
  3. C. aad False 2
  4. D. aad True 2

Correct answer: B. aad True 5

s is abcabcd, and a step of 3 picks indices 0, 3 and 6, which are a, a and d. The substring bcd is present, and the first c at or after index 3 is at index 5.

More Python Programming questions

Exams that ask this topic