ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(0.1 + 0.1 == 0.2, 0.1 + 0.1 + 0.1 == 0.3, 0.2 + 0.2 == 0.4)
- A. False False True
- B. True True True
- C. True False True
- D. True False False
Correct answer: C. True False True
Doubling 0.1 and 0.2 is exact in binary, so those sums match the literals. Adding 0.1 three times accumulates rounding error, so the total misses 0.3.
More Python Programming questions
- What is printed? python print(list(range(2, 20, 5)), list(range(-1, -10, -4)))
- What is printed? python print(len(str(71000)), 71000 % 10)
- What is printed? python print(10 -3 1000 == 1, 10 -3 1000)
- What is printed? python print(int('12' 2) + int('3' 2), len({'x' n for n in range(4)}))
- What is printed? python print(bin(6 & -6), bin(6 | -6), bin(6 ^ -6))
- What is printed? python print(hex(28 - 1), oct(29), bin(24))