Open essepuntato opened 4 years ago
from collections import deque
my_queue = deque(["Draco", "Harry", "Hermione", "Ron", "Severus"])
my_queue.popleft()
# The queue contains 'Harry', 'Hermione', 'Ron' and 'Severus'. No 'Draco' anymore
my_queue.append("Voldemort")
# The queue contains 'Harry', 'Hermione', 'Ron', 'Severus' and 'Voldemort'. We have added 'Voldemort'
my_queue.popleft()
# The queue contains 'Hermione', 'Ron', 'Severus' and 'Voldemort'. No 'Harry' anymore
Consider to have a queue obtained by processing, one by one, the elements included in the list of the first exercise, i.e.
my_queue = deque(["Draco", "Harry", "Hermione", "Ron", "Severus"])
. Describe the status of my_queue after the execution of each of the following operations:my_queue.popleft()
,my_queue.append("Voldemort")
,my_queue.popleft()
.