ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(0.1 + 0.2 != 0.3, (0.1 + 0.2) - 0.3 < 1e-16, abs((0.1 + 0.2) - 0.3) <= 5e-17)
- A. True False False
- B. True True False
- C. False True False
- D. True True True
Correct answer: B. True True False
0.1 + 0.2 - 0.3 is about 5.55e-17, which is below 1e-16 but above 5e-17. Tolerance checks must pick a value that matches the error size.
More Python Programming questions
- What is printed? python print(max('zebra', 'Zebra'), min('a', 'B'), sorted('bA', key=ord)[0], 'bA' > 'Ab')
- What is printed? python print([1, 2] < [1, 2, 0], [1, 2] < [1, 3, 0], (1, 2) < (1, 2, 0), 'ab' < 'abc')
- What is printed? python print(hex(255), hex(-255), oct(-8), bin(0), int('-ff', 16), int('0xFF', 0))
- What is printed? python print(int('8' 3) % 7, int('8' 3, 16) % 7, pow(10, 3, 7), 888 % 7)
- What is printed? python print(0.1 0.1, 0.1 0.1 == 0.01, round(0.1 0.1, 2) == 0.01, 10 0.1 0.1 10 == 1)
- What is printed? python print(len(str(777)), 777 % 1000, str(777)[-3:], int(str(777)[:3]))