ProgrammingVery hardProduct-company MCQ pattern
What is printed?
What is printed?
print(round(1e-20, 25) == 1e-20, round(123.456, 10), round(0.5 + 1e-17, 0))
- A. True 123.456 0.0
- B. True 123.456 1.0
- C. False 123.456 0.0
- D. True 123.4560000001 0.0
Correct answer: A. True 123.456 0.0
Rounding to 25 places keeps 1e-20 intact, and 123.456 has no more digits to round. 0.5 + 1e-17 is exactly 0.5 in double precision, so round-half-to-even sends it to 0.0.
More Python Programming questions
- What is printed? python def f(s): return s.lower() == s[::-1].lower() print(f('Aba'), f('Ab'), f(''), f('A'))
- What is printed? python import itertools print(list(itertools.accumulate([1, 2, 3, 4])), list(itertools.accumulate('ab'))…
- What is printed? python print(len([x for x in range(1, 100) if x % 3 == 0 or x % 5 == 0]), sum(x for x in range(1, 100) if x % 3 == 0 or x…
- What is printed? python print(bin(10)[::-1], int(''.join(reversed(bin(10)[2:])), 2), format(10, 'b').zfill(6))
- What is printed? python from collections import Counter c = Counter(a=1) c.subtract({'a': 3, 'b': 1}) print(c, c['a'] + c['b'])
- What is printed? python print(sorted([(2, 'b'), (1, 'z'), (3, 'a')], reverse=True))