Implement a stack using an array. The stack should support the following operations:
push(value: int): Adds value to the top of the stack.pop(): Removes and returns the top value from the stack. If the stack is empty, return None.peek(): Returns the top value without removing it. If the stack is empty, return None.is_empty(): Returns True if the stack is empty, otherwise False.Example 1:
stack = MyStack()
stack.push(1)
stack.push(2)
stack.peek() # Output: 2
stack.pop() # Output: 2
stack.is_empty() # Output: False
Example 2:
stack = MyStack()
stack.pop() # Output: None
stack.peek() # Output: None
stack.is_empty() # Output: True
10^4 elements.[-10^9, 10^9].stack = MyStack()
stack.push(1)
stack.push(2)
stack.peek()Output2WhyThe top of the stack is 2 after pushing 1 and 2.stack.pop()Output2WhyPopping the stack returns the last pushed value, which is 2.The stack can hold up to 10^4 elements.Values pushed will be integers in the range [-10^9, 10^9].def MyStack():