ProgrammingHardGATE CS · Product-company placement

What is printed?

What is printed?
print("%s|%r|%.3s|%5.2e|%o" % ("a", 1.0, "python", 1234.5, 8))
  1. A. a|1.0|pyt|1.23e+03|10
  2. B. a|1|pyt|1.23e+03|10
  3. C. a|1.0|python|1.23e+03|10
  4. D. a|1.0|pyt|1234.50|8

Correct answer: A. a|1.0|pyt|1.23e+03|10

%r gives repr(1.0) = '1.0'. A precision on %s truncates the string to 3 characters. %5.2e is exponent form with 2 decimals (1.23e+03), and %o prints 8 in octal as 10.

More Python Programming questions

Exams that ask this topic