ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(0.1 * 3, 1.1 * 1.1)
- A. 0.3 1.2100000000000002
- B. 0.30000000000000004 1.2100000000000002
- C. 0.3 1.21
- D. 0.30000000000000004 1.21
Correct answer: B. 0.30000000000000004 1.2100000000000002
Both products are inexact in binary floating point. 0.1 * 3 is 0.30000000000000004, and 1.1 * 1.1 prints as 1.2100000000000002.
More Python Programming questions
- What is printed? python print(5 / 2, 5 // 2, -5 / 2, -5 // 2)
- What is printed? python s = 'abc' print(s 0 == '', s[5:] == '', s[-1] + s[0])
- What is printed? python print(divmod(-9, 2), divmod(9, -2))
- What is printed? python x = [1, 2] x += x x = 2 print(x)
- What is printed? python d = dict(zip('abc', range(3))) print(d.popitem(), d)
- What is printed? python t = (3, 1, 2) print(sorted(t) == list(t), tuple(sorted(t)), t)