ProgrammingHardTCS NQT · Wipro pattern

What is printed?

What is printed?
print(str(1.0), str(1), str(1.0e0), str(10.0 ** 0), repr(1e0))
  1. A. 1.0 1 1.0 1 1.0
  2. B. 1.0 1 1 1.0 1.0
  3. C. 1 1 1.0 1.0 1.0
  4. D. 1.0 1 1.0 1.0 1.0

Correct answer: D. 1.0 1 1.0 1.0 1.0

Float literals and float results print with a decimal point, even when the value is whole. The integer 1 prints without one, and 10.0 ** 0 is a float.

More Python Programming questions

Exams that ask this topic