ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(float(1) / 3 + float(2) / 3 == 1.0, 0.1 * 0.1 * 100 == 1.0, 1 - 0.1 * 9 == 0.1)
- A. True False False
- B. False False False
- C. True True False
- D. True False True
Correct answer: A. True False False
One third plus two thirds rounds to exactly 1.0, but 0.1 * 0.1 * 100 picks up error and 1 - 0.9 is not the double 0.1.
More Python Programming questions
- What is printed? python print(f"{0.1:.20f}")
- What is printed? python def nge(a): st, res = [], [-1] len(a) for i, x in enumerate(a): while st and a[st[-1]] < x: res[st.pop()] = x…
- What is printed? python from itertools import takewhile, dropwhile a = [1, 3, 4, 6, 7, 9] print(list(takewhile(lambda x: x % 2, a))…
- What is printed? python def f(): try: return 'try' finally: print('finally', end=' ') print(f())
- What is printed? python def g(): try: return 1 finally: return 2 print(g())
- What is printed? python def bracketok(s): pairs = {')': '(', ']': '[', '}': '{'} st = [] for ch in s: if ch in '([{': st.append(ch) elif…