Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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:
- 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).
- A main function that tests the function you wrote in 1 above.
*Attached .py file contents:*
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started