ProgrammingVery hardGATE CS & IT · Infosys
What is printed?
What is printed?
print(0.0 == -0.0, -0.0, 1e16 + 1 == 1e16, 2 ** 53 + 1 == 2 ** 53)
- A. True 0.0 False False
- B. True -0.0 True False
- C. False -0.0 True False
- D. True -0.5 False False
Correct answer: B. True -0.0 True False
Positive and negative zero compare equal but print differently. 1e16 + 1 rounds back to 1e16 in double precision, while integer arithmetic keeps 2**53 + 1 exact.
More Python Programming questions
- What is printed? python import bisect xs = [1, 4, 4, 9] i = bisect.bisectleft(xs, 4) xs.insert(i, 4) print(xs, bisect.bisectright(xs, 4)…
- What is printed? python from collections import deque d = deque(range(5)) d.rotate(-2) print(list(d), d[0], d[-1])
- What is printed? python import heapq h = [] for x in [5, 1, 3]: heapq.heappush(h, x) heapq.heappush(h, 0) print([heapq.heappop(h) for in…
- What is printed? python s = 'hello' print(s.index('l'), s.rfind('l'), s.find('l', 3), s.index('lo'))
- What is printed? python import itertools print(sum(1 for in itertools.combinations(range(6), 2)), sum(1 for in…
- Which of the following statements about Python's sort is correct for CP problems?