Python程序填空练习题求解答!急!

要求使用list实现stack类:
共5个空
练习题要求补全横线处缺失的代码,实在是没有思路,求高人指点给答案,多谢!急!

img


class Stack:
    def __init__(self):
        self.__elements = []
         
 # Return true if the stack is empty
    def isEmpty(self):
        return True  #(A)
 
 # Returns the element at the top of the stack
 # without removing it from the stack.
    def peek(self):
        if self.isEmpty():
            return None
        else:
            return self.__elements  #(B)

 # Stores an element into the top of the stack
    def push(self, value):
        self.__elements.append(value) #(C)

 # Removes the element at the top of the stack and returns it
    def pop(self):
        if self.isEmpty():
            return None
        else:
            return self.__elements.pop(0)  #(D)
 # Return the size of the stack
    def getSize(self):
        return len(self.__elements)  #(E)

试试?