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))- A. nan 1 1
- B. domain 1.0 0.0
- C. domain 1.0 1
- 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
- What is printed? python print('{:e}'.format(1234.5), '{:.3g}'.format(1234567), '{:g}'.format(0.0001), '{:g}'.format(0.00001))
- What is printed? python print('é'.encode('ascii', 'replace'), 'é'.encode('ascii', 'ignore'), b'hxc3xa9llo'.decode('ascii', 'ignore')…
- What is printed? python print(10 50 // 3 20 % 100, len(bin(10 50)) - 2, (10 50).bitlength())
- What is printed? python print(1 < 2 < 3 == 3.0 != 4, 1 < 2 > 3, (1 < 2) > 3, 'a' < 'b' < 'a')
- What is printed? python x = 0b1011 print(x & ~(1 << 1), x ^ (1 << 2), x | (1 << 4), (x >> 1) & 1)
- What is printed? python words = ['bb', 'a', 'ccc', 'aa'] print(sorted(words, key=lambda w: (-len(w), w)))