ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print(int(3.99999999999999999), int(-3.7), 3.99999999999999999 == 4.0, 3)
- A. 3 -3 True 3
- B. 4 -3 True 3
- C. 4 -4 False 3
- D. 4 -3 False 3
Correct answer: B. 4 -3 True 3
The literal 3.99999999999999999 has more digits than a double holds, so it becomes exactly 4.0. int() truncates it to 4, while int(-3.7) truncates toward zero to -3.
More Python Programming questions
- What is printed? python s = 'x' 3 print(s -1 == '', s.replace('x', 'xy', 2), s.count('xx'), s.index('x', 1))
- What is printed? python print(' '.join(str(i) for i in range(3)), ','.join(f'{i:02d}' for i in (1, 10)), '|'.join(['x']), ''.join([''…
- What is printed? python print(max(3, 3.0), max(3.0, 3), min(-0.0, 0), min(0, -0.0))
- What is printed? python print('abc'[1:][::-1], 'abc'[::-1][1:], 'abcdef'[::-2][:2])
- What is printed? python print(float('nan') != float('nan'), float('inf') == float('inf'), float('inf') - float('inf') == 0, -float('inf')…
- What is printed? python x = [1, 2, 3] y = x x = x + [4] print(y, x, y is x)