0% found this document useful (0 votes)
2 views1 page

Stack Class Work

The document outlines a series of programming tasks related to stack operations in Python, including defining push and pop functions for various data types such as cars, schools, and students. It also includes tasks for filtering and pushing elements based on specific criteria, such as even numbers and marks, as well as handling customer records and stationary items. Each task requires the creation of user-defined functions to manipulate stacks effectively.

Uploaded by

rajeshbindhya02
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Stack Class Work

The document outlines a series of programming tasks related to stack operations in Python, including defining push and pop functions for various data types such as cars, schools, and students. It also includes tasks for filtering and pushing elements based on specific criteria, such as even numbers and marks, as well as handling customer records and stationary items. Each task requires the creation of user-defined functions to manipulate stacks effectively.

Uploaded by

rajeshbindhya02
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

STACK - CLASSWORK

1. Write a program to define push and pop operations in a stack named “car”. Name of the
car should be pushed and popped.
2. Write user defined functions to perform the following operations in a stack named School.
a. Push_Sch( ) → Get the name of the school from user and push it into the stack
b. Pop_Sch ( ) → Pop all the names from the stack and display it. When the stack is empty
display “School Names Empty”
3. Consider the list Lst. Write a function Peven( Lst) to push all the even elements from the
list to the stack Even.
4. Write a function in python, MakePush(Stu) and MakePop(Stu) to add a new student and
delete student from a stack Stu containing rollno, Sname and Class as list, considering them to
act as push and pop operations of the Stack data structure (CBSE Sample Paper-2019)
5. A nested list subject contains [ student, mark]. Write a user defined function Push_Name( )
to push all the students name who got mark greater than 80 into the stack distinction.
6. A list contains following record of a customer:
customer = [
["Ravi", 9876543210, "Goa"],
["Anu", 9876543222, "Delhi"],
["Hari", 9876543233, "Goa"],
["Maya", 9876543244, "Kochi"] ]
Write user defined functions to perform given operations on the stack named status:
(i) Push_element() - To Push an object containing name and Phone number of customers who
live in Goa to the stack
(ii) Pop_element() - To Pop the objects from the stack and display them. Also, display “Stack
Empty” when there are no elements in the stack.
7. A dictionary sdict contains the details of students in the format RollNo : Name. Write a
function PushStudent(sdict) to push the student details into the stack Biodata.
8. Write a function in Python, Push(SItem) where , SItem is a dictionary containing the
details of stationary items– {Sname:price}. 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.
For example: If the dictionary contains the following data:
Ditem={"Pen":106,"Pencil":59,"Notebook":80,"Eraser":25}
The stack should contain Notebook Pen
The output should be: 16
The count of elements in the stack is 2

You might also like