STACK
STACK
(ii) Pop_Cust() – To Pop the names of customers from the stack and display them.
Also, display “Underflow” when there are no customers in the
stack.
For example : If the lists with customer details are as follows :
["Siddarth", "Delux"]
["Rahul", "Standard"]
["Jerry", "Delux"]
The stack should contain
Jerry
Siddharth
The output should be:
Jerry
Siddharth
Underflow
Q2. Write a function in Python, Push (Vehicle) where, Vehicle is a dictionary containing
details of vehicles – {Car_Name: Maker}.
The function should push the name of car manufactured by ‘TATA’ (including all
the possible cases like Tata, TaTa, etc.) to the stack.
Each of these records are nested together to form a nested list. Write the following
user defined functions in Python to perform the specified operations on the stack
named travel.
(ii) Pop_element(): It pops the objects from the stack and displays them.
Also, the function should display “Stack Empty” when there are no
elements in the stack.
Q4. A list contains following record of a customer:
Write the following user defined functions to perform given operations on the stack
named ‘status’:
The function should push the names of those items in the stack who have price
greater than 75. Also display the count of elements pushed into the stack.
Notebook
Pen
Q6. Write a function in Python PUSH(Arr), where Arr is a list of numbers. From this list
push all numbers divisible by 5 into a stack implemented by using a list. Display
the stack if it has at least one element, otherwise display appropriate error
message.
Q7. 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.
Q8. Julie has created a dictionary containing names and marks as key value pairs of 6
students. Write a program, with separate user defined functions to perform the
following operations:
● Push the keys (name of the student) of the dictionary into a stack, where the
corresponding value (marks) is greater than 75.
● Pop and display the content of the stack. For example:
If the sample content of the dictionary is as follows:
R={"OM":76, "JAI":45, "BOB":89, "ALI":65, "ANU":90,"TOM":82}
The output from the program should be:
TOM ANU BOB OM
Q9. Write the definition of a user defined function Push3_5(N) which accepts a list of
integers in a parameter N and pushes all those integers which are divisible by 3 or
divisible by 5 from the list N into a stack named Only3_5.