ProgrammingEasyTCS NQT · Infosys pattern

What is printed?

What is printed?
print("abc" * 2 + "d", len("abc" * 0))
  1. A. abcdabcd 0
  2. B. abcabcd 3
  3. C. abcabcd 0
  4. D. abcabcd ''

Correct answer: C. abcabcd 0

* binds tighter than +, so "abc" * 2 + "d" is "abcabc" + "d" = "abcabcd". Repeating a string 0 times gives the empty string, whose length is 0. "abcdabcd" wrongly applies + first.

More Python Programming questions

Exams that ask this topic