ProgrammingVery hardGATE CS · Product-company placement

What is printed?

What is printed?
print(1_000 == 1000, 0.1 + 0.7, 7 / 2 == 7 // 2 + 0.5, 2 ** 0.5 ** 2, (-8) ** (1 / 3) == -2)
  1. A. True 0.8 True 2.0 False
  2. B. True 0.7999999999999999 True 2.0 True
  3. C. False 0.8 True 1.189207115002721 False
  4. D. True 0.7999999999999999 True 1.189207115002721 False

Correct answer: D. True 0.7999999999999999 True 1.189207115002721 False

Underscores in literals are ignored. 0.1 + 0.7 shows binary error. ** is right-associative: 2 ** (0.5 ** 2) = 2 ** 0.25. A negative base with a fractional exponent yields a complex number, not -2.

More Python Programming questions

Exams that ask this topic