ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
print(round(0.5 * 3), round(4.5) + round(5.5), int(2.9999999999999996), int(3.0000000000000004))
- A. 2 9 3 3
- B. 2 10 2 3
- C. 3 10 2 3
- D. 2 10 3 3
Correct answer: B. 2 10 2 3
0.5 * 3 is 1.5, which rounds to 2 under half-to-even. round(4.5) is 4 and round(5.5) is 6, and int() truncates 2.9999999999999996 to 2 but 3.0000000000000004 to 3.
More Python Programming questions
- What is printed? python print('Python' 0 + 'x', 'Py' + 'thon' 0, len('' 100))
- What is printed? python print(len(str(2100)), str(2100)[-3:], (2100) % 1000)
- What is printed? python x = 5 x += 2 x print(x, x - 2 3 2 // 9 1, x // 4 4 + x % 4)
- What is printed? python print([i for i in range(10) if i % 3 == 0][::-1], [i i for i in range(5)][-2:], len([]) == 0)
- What is printed? python print('%.2f' % 1.255, '%.2f' % 1.245, '%.1f' % 0.05, '%.1f' % 0.15)
- What is printed? python print(str(1e-4), str(1e-5), str(123456789.0), str(1234567890123456789.0))