ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
print('ab' * 2 == 'abab', 'ab' * 0 == '', 'a' * 2 + 'b' * 0 == 'aa', ('x' * 2).count('xx'))
  1. A. True True True 1
  2. B. True True False 1
  3. C. False True True 1
  4. D. True True True 2

Correct answer: A. True True True 1

Repeating a string gives the same text as writing it out, and repeating zero times gives the empty string. Adding b * 0 adds nothing, and 'xx' occurs once in 'xx'.

More Python Programming questions

Exams that ask this topic