Question: Use the attached stack.py file and add the following function that will use the stack data structure: A getStat function that gets a stack of

Use the attached stack.py file and add the following function that will use the stack data structure:

  1. A getStat function that gets a stack of integers as an input, and calculates the highest and lowest numbers in the stack, as well as the sum of all of the integers in the stack. You may manipulate the original stack any way but upon completion of the function, the original stack must be restored to its original configuration (The stack should have the same numbers before and after calling the function).
  2. A main function that tests the function you wrote in 1 above.

*Attached .py file contents:*

Use the attached stack.py file and add the following function that will

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.items)

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!