ProgrammingVery hardJEE Main · CAT placement

What is printed?

What is printed?
import math
try:
    print(math.sqrt(-1))
except ValueError:
    print('domain')
print(float('nan') ** 0, math.pow(0, 0))
  1. A. nan 1 1
  2. B. domain 1.0 0.0
  3. C. domain 1.0 1
  4. D. domain 1.0 1.0

Correct answer: D. domain 1.0 1.0

math.sqrt rejects negative input with ValueError, while the ** operator on a NaN with exponent 0 still gives 1.0. math.pow(0, 0) is 1.0 as a float.

More Python Programming questions

Exams that ask this topic