ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(f"{0.1:.20f}")- A. 0.10000000000000000555
- B. 0.10000000000000000000
- C. 0.10000000000000001000
- D. 0.1000000000000000055511
Correct answer: A. 0.10000000000000000555
Formatting with .20f shows the exact binary value of 0.1, which is 0.1000000000000000055511151231257827... rounded to 20 places. The decimal literal 0.1 is not stored exactly, which matters in digit-sensitive problems.
More Python Programming questions
- 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…
- What is printed? python import sys data = 'first line nsecondn' it = iter(data.splitlines()) print(repr(next(it)), repr(next(it).strip())…