Stack HW
Stack HW
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.