ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
s = 'abc'
print(s * 0 == '', s[5:] == '', s[-1] + s[0])
  1. A. True False ca
  2. B. False True ca
  3. C. True True ac
  4. D. True True ca

Correct answer: D. True True ca

Repeating a string zero times gives the empty string. Slicing past the end gives the empty string too. s[-1] is c and s[0] is a.

More Python Programming questions

Exams that ask this topic