print( peek() push(trueprint( size()print( is_empty() push( print( pop()print( pop()print( size()it is important to note that we could have chosen to implement the stack using list where the top is at the beginning instead of at the end in this casethe previous pop and append methods would no longer work and we would have to index position (the first item in the listexplicitly using pop and insert the implementation is shown below class stackdef __init__(self)self items [def is_empty(self)return self items =[def push(selfitem)self items insert( itemdef pop(self)return self items pop( def peek(self)return self items[ def size(self)return len(self itemss stack( push('hello' push('true'print( pop()this ability to change the physical implementation of an abstract data type while maintaining the logical characteristics is an example of abstraction at work howevereven though the stack will work either wayif we consider the performance of the two implementationsthere is definitely difference recall that the append and pop(operations were both ( this means that the first implementation will perform push and pop in constant time no matter how many items are on the stack the performance of the second implementation suffers in that the insert( and pop( operations will both require (nfor stack of size clearlyeven though the implementations are logically equivalentthey would have very different timings when performing benchmark testing basic data structures