Vous êtes sur la page 1sur 12

Programming Hands-On

Duration: 2 Hours 30 minutes


Instructions to candidates:
1. Follow the class diagram strictly. Read the problem statement, examples and the other details
provided carefully and implement the solution
2. Do not delete the project and files created by the Eclipse plug-in tool used for assessment
3. Code submitted with compilation errors may not get evaluated
4. DO NOT alter the function name or the argument list of the function that is provided to you
5. DO NOT add any new functions apart from the one given in the file where you write the
solution
6. DO NOT write codes that result in infinite loops/infinite recursive calls, because it just won’t
work!
7. Use the data in the .txt files in the testdata package for testing your solutions
8. The test cases provided are a subset of more test cases that will be used to test your code.

Guidelines:
1. The verify option checks the structural requirements and the logical requirements of the
problem statement given. Hence before submission, please check the code for all the
structural and logical requirements of the problem statement given
2. The evaluate option is not enabled
3. In case of system restart use the back up and retrieve features on the hands on client to
persist your code.
4. YOU WILL BE ALLOWED TO SUBMIT ONLY ONCE
5. Submission on hands on client will be considered as the end of assessment. You will not be
allowed to change code once submitted.
6. System will be restarted on successful submission
7. In case of any issue in submission, contact the invigilator for further steps. Wrong submissions
may lead to code not getting evaluated

NOTE: NOT adhering to the above instructions and guidelines may lead to reduction in your
score even if the code is executing without any errors
Few errors which might result in mark reduction:
1. Removal/modification of package statements
2. Infinite loops/infinite recursive calls in the code
3. Class diagram violation
4. Improper constructor prototype or definition

Question 1: Marks:5
Write your solution in the PF_solution1.py file in the PF package
Description:
Flip Jewellery store sells variety of jewels to its customers.

Write a Python program to calculate the bill_amount for customers based on the list of jewels
(purchased_jewels_list) and quantity purchased (purchased_quatity_in_grams_list).

 Any purchase with the bill amount above 20000 is entitled for 3% discount
 If any of the jewels required by the customer is not available in the store, then consider
the bill amount to be -1
 Jewels available in store with the corresponding price is given below:

avail_jewel_price_per_gram_dict = {“Bentex”: 20, "Silver”: 50, "Gold”: 2600, "Platinum”:


3000}

avail_jewel_price_per_gram_dict contains jewel as key(string) and price per gram as the


corresponding value(integer) i.e the price of “Silver” per gram is 50 Rs similarly “Gold”
per gram is 2600 Rs and so on.

Example:

purchased_jewels_list = [ "Silver", "Gold", "Platinum”]

purchased_quatity_in_grams_list = [ 20, 7, 3]

bill_amount= 27354.0

Assumption(s):

 Quantity(integer) purchased by the customer for any jewel would be always greater
than 0
 purchased_jewels_list & purchased_quatity_in_grams_list would have at least one
element each
 purchased_jewels_list & purchased_quatity_in_grams_list have one to one
correspondence. For Eg: Customer has purchased 20 grams [First element in
purchased_quatity_in_grams_list] of Silver [First element in purchased_jewels_list], 7
grams of Gold and 3 grams of Platinum
 Number of elements in purchased_jewels_list & purchased_quatity_in_grams_list
would be same

NOTE:

 Perform case-sensitive comparison


 No need to validate assumption(s)
 avail_jewel_price_per_gram_dict is initialized and provided. No need to define
 Jewel price in avail_jewel_price_per_gram_dict is on per gram basis
 Quantity purchased by the customer would be in terms of grams

For detailed explanation go to Section 1.1 in the document below

Question 2: Marks:8
Write your solution in the PF_solution2.py file in the PF package

Description:

Write a Python program that takes input_string as a parameter and returns an output_dict
based on the logic given below-

 output_dict would have two keys – “LETTERS” and “COUNT”


 Value corresponding to key “LETTERS” would be an output_list1 which would contain
the unique letters in the input_string
 Value corresponding to key “COUNT” would be an output_list2 which would contain the
count of corresponding letters in the output_list1
 Elements in output_list2 are stored in descending order of counts and the letters
corresponding to the count in output_list1
 If there are more than one letter with the same count, then the letters are stored in the
same order as they appear in input_string
Example:

input_string = 'RadeepeekaaRrm'

output_dict = {
“LETTERS” = ['e', 'a', 'R', 'd', 'p', 'k', 'r', 'm'],
“COUNT” = [4, 3, 2, 1, 1, 1, 1, 1]
}
output_list1 = ['e', 'a', 'R', 'd', 'p', 'k', 'r', 'm']

output_list2 = [4, 3, 2, 1, 1, 1, 1, 1]

Assumption:

 input_string would not be empty


 input_string would contain only alphabets/letters

Note:

 Perform case-sensitive comparison


 No need to validate assumption(s)

For detailed explanation go to Section 1.2 in the document below

Question 3: Marks:12
Write your solution in the OOP_solution.py file in the OOP package
Description:

AdvertisE is an advertising movie shooting agency in Bangalore. It is popularly known for


producing the creative advertisement movies. The automation of quotation generation system
is depicted in the class diagram given below.

Implement the class diagram below to achieve the same.


Class Diagram:

Notes:
 Do not include any extra instance/static variables and instance/static methods in the
given classes
 Case in-sensitive comparison is required to be done unless until specified explicitly
 Do not change any value or case of the given variables.
 Read notes and examples for better understanding of the logic
 In the derived classes, the order of passing arguments to the constructor would be the
base class variables followed by the derived class variables

Implementation Details:
Model class:

Constructor:

 This method initializes model_id and remuneration_per_day


 Extract the first digit of model_id and set that digit as model_grade

For Example: if the model_id is 43216 then the first digit, i.e. 4 would be assigned as the
model_grade
Assumption(s):

 model_id is a 5 digit positive non zero integer number, not more than 59999
Note: No need to validate assumption(s)

validate_remuneration_per_day() :

 This method validates the remuneration_per_day


 Identify the Minimum Limit and Maximum Limit to validate remuneration_per_day
using model_remuneration_list and model_grade
 In model_remuneration_list, considering model_grade as position of Maximum Limit of
remuneration_per_day, and the Minimum Limit is the value available in the previous
position of the same list.
For example: When the model_grade is 2, Maximum Limit is 45000.0 (the value at index
2 in model_remuneration_list) and Minimum Limit is 30000.0 (the value
at index 1 in model_remuneration_list)
 If the value of remuneration_per_day is more than the Minimum Limit and NOT more
than Maximum Limit, then return true
 Otherwise return false

AdMovies class:

validate_no_of_days_of_shooting() :

 This method validates no_of_days_of_shooting


 If the value of no_of_days_of_shooting is between 2 to 100 (inclusive of boundary
values) return true
 Otherwise return false

For Example: If no_of_days_of_shooting is 10 days, this method would return true

validate_type_of_ad_movie():

 This method validates type_of_ad_movie


 If the value of type_of_ad_movie is either ‘H’ or ‘A’ or ‘L’, return true
 Otherwise return false
Note: Perform case-sensitive comparison

For Example: If type_of_ad_movie is ‘H’, this method would return true

calculate_quotation_amount():

 This method calculates and returns the quotation_amount as per the logic given below
 Invoke validate_type_of_ad_movie(), validate_no_of_days_of_shooting() and
validate_remuneration_per_day ()
 If all the above methods return true,
 Identify budget and service_charge (in percentage) based on type_of_ad_movie
as provided in the below Table
 Identify tax based on customer_type as provided in the below Table

 Calculate actual_number_of_shooting_days as mentioned below:


o If no_of_days_of_shooting has a fractional part which is less than 0.5 then
set the value of actual_number_of_shooting_days to lower integral part else
set the value to upper integral part of the number
Eg 1: if no_of_days_of_shooting is 10.49 then
actual_number_of_shooting_days would be 10.0
Eg 2: if no_of_days_of_shooting is 10.50 then
actual_number_of_shooting_days would be 11.0

Note: You may use ceil() and floor() methods of Math library to implement
ceil and floor mathematical functions

 Calculate total_budget as,


total_budget = budget + remuneration_per_day *
actual_number_of_shooting_days

Where remuneration_per_day is retrieved from the Model class

 Calculate service_charge and tax Amount on total_budget using the identified


service_charge percentage, and tax percentage.
 Add them to total_budget.
 Set the upper integral value of the total_budget to the quotation_amount
 Return quotation_amount
 Otherwise, return -1.

For Example: If customer_type = "Public", type_of_ad_movie = "H",


no_of_days_of_shooting = 10.0 and remuneration_per_day = 35000.0 then,
quotation_amount would be 4018500.0

For details on methods which are implemented and provided go to Section 1.3 in the document
below

Section 1.1

Example:

purchased_jewels_list = [ "Silver", "Gold", "Platinum”]

purchased_quatity_in_grams_list = [ 20, 7, 3]

bill_amount= 27354.0

Example Explanation:

 Consider the first item purchased by the customer i.e "Silver”. Jewel “Silver” is available
in store and the corresponding price per gram is 50 Rs. Purchased quantity is 20 grams
and hence the price for “Silver” would be 1000 Rs.
 Similarly, “Gold” & “Platinum” are available and the corresponding purchased quantities
in grams are 7 & 3 respectively. Hence the price for “Gold” would be 18200 Rs and for
“Platinum” the price would be 9000 Rs
 The bill amount would be 28200 Rs which is entitled to 3% discount i.e 846 and hence the
totalBill amount would be 27354.0

Sample Input and Output:


Section 1.2:

Example:

input_string = 'RadeepeekaaRrm'

output_dict = {
“LETTERS” = ['e', 'a', 'R', 'd', 'p', 'k', 'r', 'm'],
“COUNT” = [4, 3, 2, 1, 1, 1, 1, 1]
}
output_list1 = ['e', 'a', 'R', 'd', 'p', 'k', 'r', 'm']

output_list2 = [4, 3, 2, 1, 1, 1, 1, 1]

Example Explanation:

 Identify the unique letters and the corresponding count for the letters in input_string
i.e ‘R’ is appearing 2 times, ‘a’ is appearing 3 times, ‘e’ is appearing 4 times similarly
letters ‘d’, ‘p’, ‘k’, ‘r’ and ‘m’ are appearing 1 time each
 Generate output_list2 in descending order of counts
i.e output_list2 = [4, 3, 2, 1, 1, 1, 1, 1]
Corresponding to the count in output_list2 the unique letters identified would be
arranged in output_list1 accordingly
i.e output_list1 = ['e', 'a', 'R', 'd', 'p', 'k', 'r', 'm']
o Highest count is 4 and hence stored as the first element in output_list2 and its
corresponding letter ‘e’ is stored in output_list1 as the first element.
o Similarly, count 3 & 2 appear next in output_list2. Hence the corresponding
letters ‘a’ & ‘R’ are stored in second and third position respectively in
output_list1
o Count 1 is the next value in output_list2 and there are 5 unique letters
corresponding to count 1 i.e ‘d’,’p’,’k’,’r’,’m’. These letters are stored in
output_list1 based on their order of occurrence in input_string
 Create the output_dict with keys “LETTERS” and “COUNT” and map the list output_list1
and output_list2 accordingly

Sample Input and Output:

Section 1.3:

Model class:

model_remuneration_list:

 This is a static list containing the following values-

Note: model_remuneration_list is initialized and provided. No need to define

AdAgencyService class:

Constructor:
 It initializes the instance variables customer_type and model.
 It invokes identify_customer_type() to verify and set the value accordingly.
 It would auto-generate quotation_id as discussed below.
 Quotation_id would be prefixed with first three characters of customer_type in
uppercase followed by the integer value starting from 1001.
For example: The first quotation_id whose customer_type is “Government”, would be
pre-fixed with “GOV” which is the first three characters of
customer_type in upper case followed by first integral value, i.e. 1001.
Thus the quotation_id is “GOV1001”.

Note: Implementation of this constructor is provided. No need to code

identify_customer_type():

 This method finds the value of customer_type


 If customer_type takes one of the values given in the Table below then the value is
retained as-is

 Otherwise customer_type would be set as “Private”


Note: Implementation of identify_customer_type() is provided. No need to code

calculate_quotation_amount ():

 This is an abstract method which would be overridden in the child class

AdMovies class:

Constructor:
 It initializes the instance variable no_of_days_of_shooting and type_of_ad_movie
Note: Implementation of this constructor is provided. No need to code

Vous aimerez peut-être aussi