ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
x = 5 x += 2 * x print(x, x - 2 * 3 ** 2 // 9 ** 1, x // 4 * 4 + x % 4)
- A. 15 13 15
- B. 15 11 15
- C. 15 13 16
- D. 16 13 15
Correct answer: A. 15 13 15
x becomes 5 + 10 = 15. 2 * 3 ** 2 // 9 ** 1 is 18 // 9 = 2, so the second value is 13. x // 4 * 4 + x % 4 rebuilds 15.
More Python Programming questions
- 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))
- What is printed? python print(18 // 4 if False else 'na', 'na' 2 + 'ba')
- What is printed? python print(all(c.islower() for c in 'abc'), any(c.isdigit() for c in 'abc'), 'abc'.isascii() and 'é'.isascii())
- What is printed? python from collections import deque d = deque('abc') d.rotate(1) d.appendleft('z') print(''.join(d), d.pop())