ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(int('12' '34') + 1, '%d' % 3.9, '%i' % -3.9, '%+d' % 0)
  1. A. 1235 3 -4 +0
  2. B. 1234 3 -3 +0
  3. C. 1235 3 -3 +0
  4. D. 1235 4 -3 +0

Correct answer: C. 1235 3 -3 +0

Adjacent string literals join before int() runs, so int('1234') + 1 is 1235. The %d and %i formats truncate floats toward zero, and %+d always shows the sign.

More Python Programming questions

Exams that ask this topic