ProgrammingVery hardJEE Advanced · CAT placement
What is printed?
What is printed?
print(2 ** -1, 2 ** -1074 > 0, 10 ** -3 == 0.001, 10 ** -2)
- A. 0.5 False True 0.01
- B. 0.5 True True 0.01
- C. 0.5 True False 0.01
- D. 0.5 True True 0.1
Correct answer: B. 0.5 True True 0.01
A negative exponent on an int gives a float. 2 ** -1074 is the smallest subnormal double and is still positive. 10 ** -3 yields the nearest double to 0.001, which equals the literal.
More Python Programming questions
- What is printed? python print(' '.join(['a', '', 'b']), ' '.join([]) == '', '-'.join('abc'), 'x'.join(['1', '2', '3']))
- What is printed? python from functools import reduce print(reduce(lambda a, b: a + b, ['x', 'y', 'z'], ''), reduce(lambda a, b: a b…
- What is printed? python print(0.1 + 0.2 > 0.3, 0.3 - 0.1 == 0.2, 0.2 + 0.2 == 0.4, 0.4 - 0.2 == 0.2)
- What is printed? python from collections import defaultdict d = defaultdict(int) for w in 'a b a c'.split(): d[w] += 1…
- What is printed? python print(sum([1e100, 1.0, -1e100]) == 1.0, sum([1, 1e100, -1e100]), 1e100 + 1.0 - 1e100)
- What is printed on the third line? python emp = [('Ravi', 30, 'IT'), ('Asha', 25, 'HR'), ('Meera', 30, 'HR'), ('Dev', 25, 'IT')] byage =…