2. PYTHON IRA SBQ 18th April
- A Cafe has below attributes:
- Registration number of type int
- Name of the venue of type string
- Cost of table of type int
- Location of café of type string
- Demand of café of type list (list of int type which denotes the demand of café for past 7 days)
- status of café of type string
Write the code to define a class to create café objects. In the class define the_init_method to initialize
the attributes of the objects to be created .
A Party has below atributes
a list of cafe objects.
a dictionary containing location and corresponding increased percentage
Write the code to define a class to create party objects. In the class define the init_ method to initialize
the attributes of the objects to be created.
Define two functions inside Party class.
1. The first function will take as input an integer value representing the registration number. Function
will return the final cost of the cafe for the given registration number from the list of cafés after applying
the increased percentage for respective café location, If the average demand of the cafe for past one
week is greater than 6 requests.
Increased percentage is calculated on the basis of cafe location as follows:
if location is "North", then there should be an increase in cost based on increased percentage of north location
if location is "South", then there should be an increase in cost based on increased percentage of south location
if location is "East", then there should be an increase in cost based on increased percentage of east location
if location is "West", then there should be an increase in cost based on increased percentage of west
location
There should not be any changes in cost if above criteria do not match.
Note: The search needs to be case sensitive.
2. The second function will take as input a string and an integer value representing the location and
budget of the cafe. This function will return the list of the cafes whose status is 'available' in the
mentioned location; from the list of cafés whose café cost is closest to the budget.
For example: budget-50000, location=North
cafés in North: café A with budget 45000
Café B with budget 40000
Method should return café A
If more than one café has closest and same budget, the function should return the list of all the café
objects found in ascending order of name of cafe.
Instructions to write main function
a. You would require to write the main section completely, hence please follow the below instruetioris for
the same
b. You would require to write the main program which is in line to the "'sample input deseription section"
mentioned below and to read the data in the same sequence.
.Create the respective objects with the given sequence of arguments to fulfil theJnit method as
mentioned in requirement, defined in the respective classes referring to the below instructions.
1.Create a list of Cafe objects which will be passed as argument while calling the functions in main. To
create the list
a. Read a number for the count of Café objects to be created and added to the list.
b. Create a Cafe object after reading the data (registration number, cafe name, cost, location, list of7
values representing the request trend of venue and status) related to It and add the object to the list to
be created. This point repeats for the number of Café objects to be created (considered in the first lineof
input) as per point #c.1. a.
d. Create a dictionary to read values for four locations (north, south, east and west) as key and its
corresponding increased percentage as value.
e. Create a Party object by passing the list created in point ##c1 and dictionary created in point d.
f.Read an integer value as input depicting the registration number of cafe to be passed as argument to
the function1
8 Call the first function mentioned above from the main section.
h. Read two values one string and one integer value as input depicting the location and budget of cafe
respectively to be passed as arguments to the function2
i. Display the value returned by the function1. Display the final cost of the cafe returned by the function
as per the requirement given.
-If function return None, then display Cafe is not found" (excluding the quotes).
jCall the second function from the main section.
k. Display the name of the cafe and the cost of the cafe returned by the function2 separated by a space.
-if function return None, then display "No Cafe is available" (excluding the quotes).
You can use/refer the below given sample input and output for more details of the format for input and
output
Sample Input description:
a. First input taken in the main section is number of Cafe objects (x) to be added to the list of Café to be
created.
b. Next set of inputs are the values for registration number, café name, cost of cafe, location, list of 7
values representing the request trend of café and status of cafe) for each café object taken one after
another and formed into a list to be stored as "Cafe". This is repeated for (x) number of Cafe objects
given in the first line of input.
c. Next set of inputs are values for venue location and percentage for different cafe locations.
d. The next line of input is the int representing the registration number of café to be passed as argument
to the first function.
e. The last line of inputs is the string and int representing the location and budget of the cafe respectively
to be passed as arguments to the second function.
Consider below sample input and output to verify your implementation.
Sample Input 1:
5
101
Meadow space
50000
North
12
13
10
18
15
8
5
Available
102
Ellison
60000
South
12
5
5
6
5
6
8
Available
103
Glamore Venue
70000
West
12
10
10
12
12
12
5
Available
104
Rajdhani
55000
West
12
10
10
12
12
12
5
Available
105
Maurya
45000
West
10
8
7
5
5
6
8
Available
North
5
South
10
West
20
East
30
102
West
57000
Sample output 1:
66000.0
Rajdhani 55000
solution explaination:
code for solution:
0 Comments