NOTE Modify append() function so that it will enable you to push more items using (Y/N): E.g  Enter your Choice: 1 Push item to stack: 12 Enter more(y/n): y Push item to stack: 15 Enter more(y/n): n  Modify pop() function so that it will confirm user want to delete item or not,(give warning that item deleted cannot be recovered) using (Delete/Cancel): E.g (D/C)  Add There (#) comment and declear all the line of this coding properly. ALGORITHM Steps:    For Array/List Based, Declare and initialize necessary variables, eg size.    Initialize an empty list as myStack;  1.Use while loop to get input from user.  2.Continue while loop until list size and defined size are same;  if len(list) == size  print “Stack overflow“  else  Read item from user  myStack = item  3.For next append operation, goto step 2.  4.For pop operation, checks that your defined size is equal to list size or not;  if len(list) == size print "Stack underflow"  else  myStack = pop(); Display item  5.For next pop operation, goto step 4.  6.Stop    Modify the algorithm given, stack.py, to create a Menu that enable user to enter option for stack operations  append()  pop()  Count last item of the list  len(list) == 0 and check whether list is full or not  len()  print()

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

NOTE

Modify append() function so that it will enable you to push more items using (Y/N): E.g 

Enter your Choice: 1 Push item to stack: 12 Enter more(y/n): y Push item to stack: 15 Enter more(y/n): n 

Modify pop() function so that it will confirm user want to delete item or not,(give warning that item deleted cannot be recovered) using (Delete/Cancel): E.g (D/C) 

Add There (#) comment and declear all the line of this coding properly.

ALGORITHM Steps: 

 

For Array/List Based, Declare and initialize necessary variables, eg size. 

 

Initialize an empty list as myStack

1.Use while loop to get input from user. 

2.Continue while loop until list size and defined size are same; 

if len(list) == size 

print “Stack overflow“ 

else 

Read item from user 

myStack = item 

3.For next append operation, goto step 2. 

4.For pop operation, checks that your defined size is equal to list size or not; 

if len(list) == size print "Stack underflow" 

else 

myStack = pop(); Display item 

5.For next pop operation, goto step 4. 

6.Stop 

 

Modify the algorithm given, stack.py, to create a Menu that enable user to enter option for stack operations 

  • append() 
  • pop() 
  • Count last item of the list 
  • len(list) == 0 and check whether list is full or not 
  • len() 
  • print() 

 

Example of INPUT / OUTPUT
Enter the operation to be performed: 1) append 2) pop 3) print 4) len 5) exit
1
Enter the number to be pushed: 11
Enter the operation to be performed: 1) append 2) pop 3) print 4) len 5) exit
1
Enter the number to be pushed: 22
Enter the operation to be performed: 1) append 2) pop 3) print 4) len 5) exit
1
Enter the number to be pushed: 33
Enter the operation to be performed: 1) append 2) pop 3) print 4) len 5) exit
2
The number Popped is: 33
Enter the operation to be performed: 1) append 2) pop 3) print 4) len 5) exit
3
The stack is 11 22
Enter the operation to be performed: 1) append 2) pop 3) print 4) len 5) exit
4
The size of the stack is 2
Transcribed Image Text:Example of INPUT / OUTPUT Enter the operation to be performed: 1) append 2) pop 3) print 4) len 5) exit 1 Enter the number to be pushed: 11 Enter the operation to be performed: 1) append 2) pop 3) print 4) len 5) exit 1 Enter the number to be pushed: 22 Enter the operation to be performed: 1) append 2) pop 3) print 4) len 5) exit 1 Enter the number to be pushed: 33 Enter the operation to be performed: 1) append 2) pop 3) print 4) len 5) exit 2 The number Popped is: 33 Enter the operation to be performed: 1) append 2) pop 3) print 4) len 5) exit 3 The stack is 11 22 Enter the operation to be performed: 1) append 2) pop 3) print 4) len 5) exit 4 The size of the stack is 2
Expert Solution
steps

Step by step

Solved in 3 steps with 8 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY