Skip to main contentSkip to solution

What is the purpose of following function?

def fun (myqueue):

if not(isEmpty(myqueue)):

return myqueue.pop(0)

else:

print("Empty")

Solution

✅ Correct Option: 1

If the queue is not empty, myqueue.pop(0) removes and returns the element at index 0, which is the front of the queue. If it is empty, the function prints "Empty". This is the dequeue operation.


Option 2: rear deletion would be pop() with no argument, which removes the last element.

Option 4: pop(0) removes the element as well as returning it. Peek would use myqueue[0].

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question