ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(0.1 + 0.2 + 0.3 == 0.6, 0.6 == 0.3 * 2, 0.3 * 2 == 0.6)
- A. False True True
- B. True True True
- C. False False True
- D. False True False
Correct answer: A. False True True
Adding 0.1, 0.2 and 0.3 left to right gives 0.6000000000000001, which is not 0.6. 0.3 * 2 is exactly the double for 0.6, so the other two comparisons hold.
More Python Programming questions
- What is printed? python print(sorted([10, 2, 33], key=str), sorted(['10', '2', '33'], key=int))
- What is printed? python print('%.2f' % 0.125, '%.2f' % 0.375, '%.1f' % 0.05, '%.0f' % 1.5)
- What is printed? python print(-17 % -5, 17 % -5, -17 % 5, -(17 % 5))
- What is printed? python a = 'ab' b = a 3 print(b.count('ab'), b.count('aba'), len(b.split('b')))
- What is printed? python print(0.1 10 == 1.0, 0.1 10, sum([0.1] 10) == 1)
- What is printed? python print(int(1e15 + 0.3) == 1015, round(1e15 + 0.3) - 1015)