Test Index

CBSE Class 12 Computer Science 2023 Paper Set 4 Get it on Google PlayDownload on the App Store

© examsnet.com
Question : 30 of 35
Marks: +1, -0
(a) A list contains following record of customer:
[Customer_name, Room Type]
Write the following user defined functions to perform given operations on the stack named 'Hotel' :
(i) Push_Cust() – To Push customers’ names of those customers 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.
For example :
If the lists with customer details are as follows :
["Siddharth", "Delux"]
["Rahul", "Standard"]
["Jerry", "Delux"]
The stack should contain
Jerry
Siddharth
The output should be:
Jerry
Siddharth
Underflow
OR
(b) Write a function in Python, Push (Vehicle) where, Vehicle is a dictionary containing details of vehicles – {Car_Name: Maker}.
The function should push the name of car manufactured by ‘TATA’ (including all the possible cases like Tata, TaTa, etc.) to the stack.
For example:
If the dictionary contains the following data:
Vehicle={"Santro":"Hyundai","Nexon":"TATA","Safari":"Tata"}
The stack should contain
Safari
Nexon
Advertisements
Go to Question: