Check sibling questions
Computer Science - Class 12
Chapter 3 - Stacks

Write a function in Python POP(Arr), where Arr is a stack implemented by a list of numbers. The function returns the value deleted from the stack.

Answer:

def POP(Arr):

top=len(Arr)-1

if len(Arr)!=0:

deleted_val=Arr[top]

Arr.pop()

else:

print("Stack is Empty")

return deleted_val

 

Slide27.JPG

 

Are ads bothering you?


Transcript

Write a function in Python POP(Arr), where Arr is a stack implemented by a list of numbers. The function returns the value deleted from the stack. Answer: def POP(Arr): top=len(Arr)-1 if len(Arr)!=0: deleted_val=Arr[top] Arr.pop() else: print("Stack is Empty") return deleted_val

Davneet Singh's photo - Teacher, Engineer, Marketer

Made by

Davneet Singh

Davneet Singh is a graduate from Indian Institute of Technology, Kanpur. He has been teaching from the past 12 years. He provides courses for Maths and Science at Teachoo.