ProgrammingVery hardGATE CS · Product-company placement
What is printed?
What is printed?
import sys print(sys.float_info.epsilon, 1.0 + sys.float_info.epsilon > 1.0, 1.0 + sys.float_info.epsilon / 2 > 1.0)
- A. 2.220446049250313e-16 True True
- B. 1.1102230246251565e-16 True False
- C. 2.220446049250313e-16 True False
- D. 2.220446049250313e-16 False False
Correct answer: C. 2.220446049250313e-16 True False
epsilon is the gap between 1.0 and the next double. Half of epsilon is a tie that rounds back to 1.0 under round-half-to-even, so adding it changes nothing.
More Python Programming questions
- What is printed on the first line? python print(263 2-63 == 1.0, 264 + 1.0 - 264, (264 + 1) - 264) print(float(264 + 1) - float(264))
- What is printed on the first line? python print(7 % -3, -7 % 3, 7 % 3, -7 % -3) print(-7 // -3, 7 // -3, -7 // 3)
- What is printed on the second line? python def mod(a, m): r = a % m return r + m if r < 0 else r print(mod(-1, 5), mod(-5, 5), mod(-6, 5))…
- What is printed on the first line? python M = 109 + 7 print((-1) % M, (262) % M, pow(3, M - 2, M) 3 % M) print(((-5) % 3) ((-5) % 3), (-5…
- What is printed on the second line? python a, b = -13, 4 print(a // b, a % b, a // b b + a % b == a) print(int(a / b), int(-3.25), -3.25…
- What is printed on the first line? python n = -17 print(n >> 2, n // 4, n & 3, n % 4) print(n << 1, (n << 1) >> 1 == n, ~n)