ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(10 ** -2, 10.0 ** -2, 1_000 * 1_0, 2 ** -1 * 4)
  1. A. 0.01 0.01 10000 0.5
  2. B. 0.01 0.01 10000 2.0
  3. C. 0.01 0.01 10000 2
  4. D. 0.01 0.01 1000 2.0

Correct answer: B. 0.01 0.01 10000 2.0

A negative int exponent on an int base gives a float, so 10 ** -2 is 0.01. 2 ** -1 is 0.5, and multiplying by 4 gives 2.0 as a float, not the int 2.

More Python Programming questions

Exams that ask this topic