ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
print(0.2 + 0.4 + 0.1 == 0.7, 0.1 + (0.2 + 0.4) == 0.7, 0.2 + 0.1 + 0.4 == 0.7)
- A. False False True
- B. False False False
- C. False True True
- D. True False False
Correct answer: B. False False False
0.2 + 0.4 is 0.6000000000000001, and adding 0.1 pushes the total past 0.7, so each grouping misses the target. The printed values are all False, even though the mathematical sum is exactly 0.7.
More Python Programming questions
- What is printed? python print(sorted([(1, 'b'), (1, 'a'), (0, 'z')], reverse=True)[0])
- What is printed? python print(list(map(len, ['', 'ab', 'abc'])), sum(map(len, ['', 'ab', 'abc'])))
- What is printed? python print(10 in range(0, 20, 5), 11 in range(0, 20, 5))
- What is printed? python print(sum(range(1, 101)) 2 - sum(i i for i in range(1, 101)))
- What is printed? python print(len(str(264)), sum(map(int, str(264))))
- What is printed? python print(all(int(c) % 2 == 0 for c in '24680'), any(c in 'aeiou' for c in 'rhythm'))