TAGORE INTERNATIONAL SCHOOL
VASANT VIHAR
Class: XII
P RACTICAL FILE ASSIGNMENT NO 10
Stacks
1. A list contains the following record of books:-
[“truth”, “vindhyas”, “daffodils”, “devil”]
rite the following user defined functions to perform the given operations on the
W
stack named ‘books’:-
a) Push(stack,title) : for adding the elements in the stack where stack is an empty list
title is the element passed for adding it in the stack
) Pop(stack) : Remove the element from the stack. Check the emptiness of the
b
stack
before popping each element.
2. W
rite the following user defined function to perform the given operations on the
stack named ‘quotes’:-
a. push(): To push a string accepted from the user into the stack.
b. pop(): To pop the words from the stack and display the words in reverse
order
For example:-
If string is “Hello World”
The output should be “World Hello”
3. D
efine the function pop() for the previous question to pop string from the stack and
display the string in reverse order.
For example:-
If string is “Hello World”
The output should be “dlorW olleH”
4. A list following record of customer:-
[“Customer_name”, “Room Type”]
rite the following user defined functions to perform given operations on the stack
W
named ‘Hotel’:-
i) Push_Cust(): To Push customers’ names of those customers who are staying in
‘Deluxe’ Room Type.
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.
F or example:
if lists with customer details are as follows:
[“Siddharth”, “Delux”]
[“Rahul”, “Standard”]
[“Jerry”, “Delux”]
The stack should contain:-
Jerry
Siddharth
The Output should be:-
Jerry
Siddharth
Underflow
5. W
rite a function in Python, Push(Vehicle) where, Vehicle is a dictionary containing
details of vehicles: {Car_Name: Maker}.
T he function should push the name of the car manufactured by ‘TATA’(in all cases
possible) to the stack.
For example:-
If the dictionary contains the following data:
Vehicle={“Santro”: “Hyundai”, “Nexon”: “TATA”, “Safari”: “Tata”}
The stack should contain:-
Safari
Nexon