ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(10**-1 + 10**-1 + 10**-1 == 0.3, 1/10 + 1/10 + 1/10 == 0.3, 10**-1 == 1/10)
- A. True True True
- B. False False True
- C. False True True
- D. False False False
Correct answer: B. False False True
10 ** -1 is the same float as 1 / 10, so the sums are identical and both miss 0.3 by one unit in the last place. The equality of the two single values is True.
More Python Programming questions
- What is printed? python print(sorted([3, 1, 2], reverse=True) == [3, 2, 1], [3, 1, 2][::-1], sorted('cab')[::-1])
- What is printed? python print(int(str(7) 3) 2 % 10, 111 2, (11 2) 10 + 1)
- What is printed? python n = float('nan') print(n in [n], float('nan') in [n], n == n, [n] == [n])
- What is printed? python print(0.1 + 0.2 in [0.3], 0.3 in [0.1 + 0.2], round(0.1 + 0.2, 1) in [0.3])
- What is printed? python print(1 in {1.0: 'a'}, '1' in {1: 'a'}, 1.0 in {True: 1}, {1, True, 1.0})
- What is printed? python d = {} d[1.0] = 'x' d[1] = 'y' print(d, len(d), d[True])