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

Stack HW

Homework

Uploaded by

mukuldhangar2008
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)
21 views1 page

Stack HW

Homework

Uploaded by

mukuldhangar2008
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
You are on page 1/ 1

HOME WORK-4 (STACK)

1. Consider the following user defined functions in python and perform the specified operations
on a stack named BigNums.
(i) PushBig( ) : It checks every number from the list Nums and pushes all such numbers
whichnhave 5 or more digits into the stack, BigNums.
(ii) PopBig( ) : It pops the number from the stack, Bignums and display them. The
function should also display “Stack Empty” when there are no more numbers left in
the stack.
2. A list contains following record of customer : [Customer-Name, Room Type]
Example : L= [[“Siddarth”,”Delux”],[“Rahul”,”Standard”],[“Jerry”,”Delux”]]
Write the following user defined functions to given operations on the stack named „HOTEL‟ :
(i) Push_Cust( ) : To push customers‟ name of those who are staying in ‘Delux’ 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.
3. Write a function in python , Push(Vehicle), where Vehicle is a dictionary containing details of
vehicles : { Car_Name : Maker }
Example : Vehicle={“Santro”:”Hyundai”, “Nexon”:”Tata”,”Safari”:”Tata”}
The function should push the name of car manufactured by “TATA”(including all the
possible cases like Tata,TaTa,tata etc.) to the stack.

4. A list, NList contains following record as list elements: [City, Country, distance from Delhi]
Each of these records are nested together to form a nested list.
Write the following user defined functions in Python to perform the specified operations on
the stack named travel.
(i) Push_element(NList): It takes the nested list as an argument and pushes a list object
containing name of the city and country, which are not in India and distance is less
than 3500 km from Delhi.
(ii) Pop_element(): It pops the objects from the stack and displays them. Also, the
function should display “Stack Empty” when there are no elements in the stack.

5. Write the user defined functions to do the following :


 PUSH(Arr) , where Arr is a list of numbers, From this list Push all numbers divisible
by 5 into a a stack implemented by using a list.
 POP( ): It pops the objects from the stack and displays them. Also, the function should
display “Stack Empty” when there are no elements in the stack
6. A list contains the following record of a customer : [Customer_name, Phone_Number, City]
Write the following 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. 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.

You might also like