ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(3 * 'ab' == 'ab' * 3, 'ab' * 3 == 'aba' + 'bab', [0] * 3 == [0, 0, 0], ['a'] * 2 == 'aa')
  1. A. True True False False
  2. B. True True True False
  3. C. True False True False
  4. D. False True True False

Correct answer: B. True True True False

Repetition by the same count gives the same sequence, and 'aba' + 'bab' is 'ababab'. A list of one-letter strings is not equal to a string, even when the text looks the same.

More Python Programming questions

Exams that ask this topic