ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print(int(0.1 * 10), round(0.1 * 10, 10) == 1, 0.1 * 10 == 1)
- A. 1 False True
- B. 1 True True
- C. 0 True True
- D. 1 True False
Correct answer: B. 1 True True
0.1 * 10 is exactly 1.0 in binary, so int gives 1 and both comparisons are True. The rounding step is not needed here, so the answer is simply 1 True True.
More Python Programming questions
- What is printed? python print(abs(-0.0), abs(-3), abs(True), abs(-2 63))
- What is printed? python print(bool(0.0 or 0j), bool(0j or 1j), 0j == 0, 1j 1j)
- What is printed? python print([x for x in range(5) if x % 2], [x for x in 'a1b2' if x.isdigit()], {x % 3 for x in range(6)})
- What is printed? python print(str(()), str([()]), repr(('a',)), str(('a', 1)))
- What is printed? python x = 10 def f(): return x x = 20 print(f(), (lambda y=x: y)(), [lambda: i for i in range(2)][1]())
- What is printed? python print(list(map(int, '1 2 3'.split())), list(map(str.upper, 'ab')), sum(map(int, '9' 3)) % 7)