XII Stack Worksheet
XII Stack Worksheet
Stack Worksheet
XII
11. Write the technical term used for adding element in stack.
12. What happen when you try to delete an element from an empty stack?
student name
act as
1
14. Write a menu based program to add, delete and display the record of
contains the fields: Hostel number, Total Students and Total Rooms.
15. Write a function push() to add the names one by one from a list of
16. Define a function pushodd() to append only odd numbers from a list
one by one.
of students who
(ii) popElement() - To Pop the objects from the stack and display them.
For example:
2
[“Sajal”,”77777777777”,”VIII”,”A”]
[“Yash”, “1010101010”,”XII”,”A”]
[“Swatantra”, “8888888888”]
[“Yash”, “1010101010”]
[“Yash”, “1010101010”]
[“Swatantra”, “8888888888”]
Stack Empty
The function should push the names of those items in the stack who have
For example:
“Watch”: 250}
3
Pen
Notebook
Watch
19. A dictionary contains the names of some cities and their population in crore.
Write a python function push(stack, data), that accepts an empty list, which
is the stack and data, which is the dictionary and pushes the names of those
For example :
then the execution of the function push() should push India and USA on the
stack.
21. A list of numbers is used to populate the contents of a stack using a function
push(stack, data) where stack is an empty list and data is the list of numbers.
The function should push all the numbers that are even to the stack. Also
write the function pop() that removes the top element of the stack on its
each call.
4
5