Janardan Bhagat Shikshan Prasarak Sanstha's
Ramsheth Thakur Public School, Kharghar
Plot No.11 & 11A, Sec-19, Kharghar, Navi Mumbai-410210, Tel No-022-27744410, 27744577
CBSE Affiliation No : 1130299 School No. 30310 U-Dise No. 27240806133
(2025-26)
Subject : COMPUTER SCIENCE(083)
Std & Div: XII ____
Topic: Stack
Q.1] Payal has created a dictionary D, containing names and salary as key value
pairs of 5 employees. Write separate functions to perform the following
operations:
●PUSH(HS, D), where HS is the stack and D is the dictionary which containing
names and salaries. Push the keys (name of the employee) of the dictionary into
a stack, where the corresponding value (salary) is greater than ₹75,000.
● POP(HS), where HS is the stack. Pop and display the content of the stack.
● PEEK(HS),This function displays the topmost element of the stack without
deleting it. If the stack is empty, the function should display 'None'.
Q.2] Write the following user defined functions with reference to STACK-
• Write the definition of a user-defined function PUSH_ODD(N) which accepts a
list of integers in a parameter `N` and pushes all those integers which are odd
from the list `N` into a Stack named `OddNumbers`.
For example- If the integers input into the list `VALUES` are: [10, 5, 8, 3, 12,11]
Then the stack `OddNumbers` should store: [5,3,11]
• Write function POP_ODD() to pop the topmost number from the stack and
returns it. If the stack is already empty, the function should display "Empty".
• Write function DISP_ODD() to display all element of the stack without deleting
them. If the stack is empty, the function should display 'None'.
Q.3] You have a stack named ItemsStack that contains records of Items. Each
Item record is represented as a list containing Item_title, name, and price. Write
the following user-defined functions in Python to perform the specified
operations on the stack ItemsStack:
(I) push_Item(ItemsStack, new_Item): This function takes the stack ItemsStack
and a new Item record new_Item as arguments and pushes the new Item
record onto the stack.
(II) pop_Item(ItemsStack): This function pops the topmost Item record from the
stack and returns it. If the stack is already empty, the function should display
"Underflow".
(III) peep(ItemsStack): This function displays the topmost element of the stack
without deleting it. If the stack is empty, the function should display 'None'.
Q.4] Write the definition of a user-defined function `push_div(N)` which accepts
a list of integers in a parameter `N` and pushes all those integers which divisible
by 5 from the list `N` into a Stack named `Numbers`. Write function pop_div() to
pop the topmost number from the stack and returns it. If the stack is already
empty, the function should display "Empty".
Write function Disp_div() to display all element of the stack without deleting
them. If the stack is empty, the function should display 'None' For example: If
the integers input into the list VALUES are: [15, 25, 28, 23, 20] Then the stack
`Numbers` should store: [15, 25, 20]