ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(0.1 * 3, 1.1 * 1.1)
  1. A. 0.3 1.2100000000000002
  2. B. 0.30000000000000004 1.2100000000000002
  3. C. 0.3 1.21
  4. D. 0.30000000000000004 1.21

Correct answer: B. 0.30000000000000004 1.2100000000000002

Both products are inexact in binary floating point. 0.1 * 3 is 0.30000000000000004, and 1.1 * 1.1 prints as 1.2100000000000002.

More Python Programming questions

Exams that ask this topic