ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
from collections import deque
d = deque('abc')
d.rotate(1)
d.appendleft('z')
print(''.join(d), d.pop())- A. zcab a
- B. abcz c
- C. zbca b
- D. zcab b
Correct answer: D. zcab b
rotate(1) moves the last item to the front, so the deque is c, a, b. appendleft puts z in front, and pop removes b from the right.
More Python Programming questions
- What is printed? python print(len(bin(255)), bin(255).count('0'), bin(-255).count('1'))
- What is printed? python print('%s' % 'x' 3, '%s' 2 % ('a', 'b'), '%s' % ('x' 3))
- What is printed? python print(3 'a' + 'b', 'c' 3 + 'd')
- What is printed? python print(int(3.7 10), int(0.7 10), 3.7 10 == 37, 0.7 10 == 7)
- What is printed? python print(sorted([True, 2, 1.5, False, -1]))
- What is printed? python print(1 if [] == [] is True else 0, [] is [], () is ())