ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
print('1' + '2' * 3, '1' * 2 + '2', len('ab' * 0 + 'c' * 3), 'x' * 2 == 'xx')
  1. A. 1222 112 3 False
  2. B. 1222 122 3 True
  3. C. 1222 112 3 True
  4. D. 1222 112 4 True

Correct answer: C. 1222 112 3 True

Multiplication by a number binds tighter than +, so the string repetition happens before concatenation. 'ab' * 0 is empty, leaving the three c characters.

More Python Programming questions

Exams that ask this topic