Question: use stack as your starting point for both tye stack2.py and stack3.py . use python language please class Stack: def __init__(self): self.items [] def isEmpty(self):

use stack as your starting point for both tye stack2.py and stack3.py . use python language please  use stack as your starting point for both tye stack2.py and
stack3.py . use python language please class Stack: def __init__(self): self.items []

class Stack: def __init__(self): self.items [] def isEmpty(self): return self.items [] def push(self, item): self.items.append(item) def pop(self): return self items.pop() def peek(self) return self.items[len(self.items)-1] def size(self): return len(self atems) 1. Motivating questions. a. Using the Stack dass, what happens when you try to do a pop() operation on an empty Stack? b. Using the Stack class, what happens when you try to do a peek() operation on an empty Stack? 2. Create a new Stack class, called Stack2, and modify the following methods. a. pop() 1. Return None when the stack is empty. b. peek() 1. Return None when the stack is empty. In your stack2.py source code file, add test functions and test code to test the modifications you made to each method. C. 3. Create a new Stack class, called Stack3, and modify the following methods. a. pop() 1. Raise an Exception when the stack is empty. Include an appropriate message to be displayed when the Exception is printed. The statement will look something like: raise Exception ("appropriate message") b. peeki) Raise an exception when the stack is empty. Include an appropriate message to be displayed when the Exception is printed C. In your stack3.py source code file, add test functions and test code to test the modifications you made to each method 4. What files should you submit? Submit two Python source code files - stack2.py and stack3.py - as described in steps 2 and 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!