ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print('%d items' % 3, '%s' % 3.0, '%s' % None, '%r' % None)
  1. A. 3 items 3 None None
  2. B. 3 items 3.0 None None
  3. C. 3 items 3.0 None 'No'
  4. D. 3 items 3.0 NoneType None

Correct answer: B. 3 items 3.0 None None

%d prints the integer, and %s uses str() on the float, which keeps the .0. None formats as None under both %s and %r.

More Python Programming questions

Exams that ask this topic