Q1.
Vignesh has created a dictionary “employee” with employee name as key and
their salary as values. Write a program to perform the following operations in
Python:
(a) Push the names of those employees into a stack where the salary is less than 50000
(b) Pop the elements of the stack and display those names.
(OR)
Harsha has created a list 'mylist' of 10 integers. You have to help him to create
a stack by performing the following functions in Python:
(a) Traverse each element of the list and push all those numbers into the stack
which are divisible by 3. (b) Pop from the stack and display all the content.
Q2.Write a function in Python PUSH_IN(L), where L is a list of numbers.
From this list, push all even numbers into a stack which is implemented by
using another list.
(OR) Write a function in Python POP_OUT(Stk), where Stk is a stack
implemented by a list of numbers. The function returns the value which is
deleted/popped from the stack.
Q3. Write a program to create a Stack of Student records contains Roll,
Name and Percentage mark. Perform the following:
(a) Display the details of Second Topper Student
(b) Insert a new Record to a Stack
(c) Remove the student details scored less than 90% and display
Stack
(OR)
Alam has a list containing 10 integers. You need to help him create a program
with separate user defined functions to perform the following operations based
on this list.
● Traverse the content of the list and push the even numbers into a stack.
● Pop and display the content of the stack. For Example:
If the sample Content of the list is as follows: N=[12, 13, 34, 56, 21, 79, 98, 22, 35, 38]
Sample Output of the code should be: 38 22 98 56 34 12
Q4. Write a function push (student) and pop (student) to add a new student
name and remove a student name from a list student, considering them to act as
PUSH and POP operations of stack Data Structure in Python
Q5. Write a function in python, PUSH(rollno) and POP() to add a new rollno
and delete a rollno from a List of students, considering them to act as push and
pop operations of the Stack data structure. (OR)
Write add(bookname) and delete method in python to add bookname and
remove bookname considering them to act as push() and pop() operations in
stack.
Q6. Jiya has a list containing 8 integers. You need to help her create a program
with two user defined functions to perform the following operations based on
this list.
● Traverse the content of the list and push those numbers into a stack which
are divisible by both 5 and 3. ● Pop and display the content of the stack.
Q7. Write a function in python, Push(Package) and Pop(Package) to add
details of employee contain information (Empid, Ename and Salary) in the
form of tuple in Package and delete a Package from a List of Package
Description, considering them to act as push and pop operations of the Stack
data structure.
Q8. Reva has created a dictionary containing Product names and prices as key
value pairs of 4 products. Write a user defined function for the following:
● PRODPUSH() which takes a list as stack and the above dictionary as the parameters.
Push the keys (Pname of the product) of the dictionary into a stack, where the
corresponding price of the products is less than 6000. Also write the statement
to call the above function.
For example: If Reva has created the dictionary is as follows:
Product={"TV":10000, "MOBILE":4500, "PC":12500,
"FURNITURE":5500}
The output from the program should be: [ ‘FURNITURE’, ‘MOBILE’]
OR
Shaan has a list containing 14 integers. You need to help him create a program
with separate user defined function to perform the following operation based
on this list.
● NUMUSH() which takes a list as stack and the above list of numbers as the
parameters. push the numbers of the list which are divisible by 5 into a stack.
Also write the statement to call the function.
For Example: If the sample Content of the list is as follows:
M=[2, 10,13,17,25,32,38,44, 56, 60,21, 74, 35,15]
Sample Output of the code should be: [10, 25, 60, 35, 15]
Q9. Write a function in Python PUSH_IN(L), where L is a list of numbers. From this list,
all even numbers into a stack which is implemented by using another list.
OR
Write
push a function in Python POP_OUT(Stk), where Stk is a stack implemented
by a list of numbers. The function returns the value which is deleted/popped
from the stack.
Q10. Nandu has created a dictionary containing countries and continent as
key value pairs of 6 countries. Write a program, with separate user defined
functions to perform the following operations: ● Push the keys (name of the
country) of the dictionary into a stack, where country belongs to continent
“ASIA”.
● Pop and display the content of the stack. For example: If the sample
content of the dictionary is as follows:
R={"UK":”EUROPE, "INDIA":”ASIA”, "CHINA":”ASIA”, "EGYPT":”AFRICA”,
"CUBA":”AMERICA”, "JAPAN":”ASIA”}
The output from the program should be: JAPAN CHINA INDIA
Q11. Vaishnav has a list containing names of 10 cities. You need to help him
create a program with separate user defined functions to perform the following
operations based on this list:
. ● Traverse the content of the list and push those names which are having
more than 5 characters in it.
● Pop and display the content of the stack. For Example: If the sample
Content of the list is as follows:
N=[“Paris”, “England”, “Mumbai”, “Delhi”, “London”]
Sample Output of the code should be: London Mumbai England