ProgrammingVery hardJEE Advanced · CAT placement
What is printed?
What is printed?
x = 0.1 print((0.5).as_integer_ratio(), (0.1).as_integer_ratio()[1] == 2**55)
- A. (1, 2) False
- B. (1, 10) True
- C. (1, 2) True
- D. (1, 2) 2**55
Correct answer: C. (1, 2) True
0.5 is exactly one half, so its ratio is (1, 2). The float 0.1 is stored as a fraction with denominator 2**55, so the second check is True.
More Python Programming questions
- What is printed? python import operator print(operator.index(5), operator.mod(-7, 3), operator.floordiv(-7, 3))
- What is printed? python print(sorted(['b', 'B', 'a', 'A'], key=lambda s: s.swapcase()))
- What is printed? python print(len(set('mississippi')), sorted(set('mississippi')))
- What is printed? python print(7 -1 == 1 / 7, pow(7, -1, 13) 7 % 13, (7 2) % 13, 2 3 2 % 10)
- What is printed? python x = [0] 3 x[0] += 1 y = [[0]] 2 y[0][0] += 1 print(x, y)
- What is printed? python print(int(float('1e16')) + 1, float(int(260) + 1) == float(260))