ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
print(3 * 'a' + 'b', 'c' * 3 + 'd')
  1. A. aaba cccd
  2. B. aaab dccc
  3. C. aaab cdcd
  4. D. aaab cccd

Correct answer: D. aaab cccd

Multiplication binds tighter than +, so 3 * 'a' + 'b' is aaab. The same rule gives cccd for the second string.

More Python Programming questions

Exams that ask this topic