from typing import Any, Optional from adts import Stack, Queue def…

Question Answered step-by-step from typing import Any, Optional from adts import Stack, Queue def… from typing import Any, Optionalfrom adts import Stack, Queuedef peek(stack: Stack) -> Optional[Any]:   “””Return the top item on the given stack.   If the stack is empty, return None.   Unlike Stack.pop, this function should leave the stack unchanged when the   function ends. You can (and should) still call pop and push, just make   sure that if you take any items off the stack, you put them back on!   >>> stack = Stack()   >>> stack.push(1)   >>> stack.push(2)   >>> peek(stack)   2   >>> stack.pop()   2   “””   if Stack.is_empty()==True:       return None   else:       return Stack(len(Stack)-1) def reverse_top_two(stack: Stack) -> None:   “””Reverse the top two elements on .   Precondition: has at least two items.   >>> stack = Stack()   >>> stack.push(1)   >>> stack.push(2)   >>> reverse_top_two(stack)   >>> stack.pop()   1   >>> stack.pop()   2   >>> stack.is_empty()   True   “””   x = Stack.pop()   y = Stack.pop()   Stack.push(x)   Stack.push(y)def remove_all(queue: Queue) -> None:   “””Remove all items from the given queue.   >>> queue = Queue()   >>> queue.enqueue(1)   >>> queue.enqueue(2)   >>> queue.enqueue(3)   >>> remove_all(queue)   >>> queue.is_empty()   True   “””   for i in range(Queue):       Queue.dequeue()def remove_all_but_one(queue: Queue) -> None:   “””Remove all items from the given queue except the last one.   Precondition: contains at least one item.                 or: not queue.is_empty()   >>> queue = Queue()   >>> queue.enqueue(1)   >>> queue.enqueue(2)   >>> queue.enqueue(3)   >>> remove_all_but_one(queue)   >>> queue.is_empty()   False   >>> queue.dequeue()   3   >>> queue.is_empty()   True   “””   for i in (range(Queue)-1):       Queue.dequeue()if __name__ == ‘__main__’:   # import doctest   # doctest.testmod()   # Remember, to get this to work you need to Run this file, not just the   # doctests in this file!   import python_ta   python_ta.check_all(config={       ‘extra-imports’: [‘adts’]   })  There are 4 functions. Tell me the error and the codes after fixing the errorThanks Computer Science Engineering & Technology Python Programming CSC 160 Share QuestionEmailCopy link Comments (0)