Car insurance company XYZ considers various factors for calculating the price of their products for th tomers. The sales team has decided to provide certain discounts to attract more customers. They woul e to adjust the price according to the following table of information: 1. The base monthly rate is calculated as follows: Price of The Car 10k and below Base Monthly Rate 0.5% of the price 1% of the price 2% of the price 10k to 25k 25k and over 2. Based on the age of the driver, the following discounts are offered on the base monthly rate: Discount Applied Age 18 - 25 25 - 40 40 - 60 60 and over 0% 5 % 10 % 15 % 3. For students attending GMU, they have considered a promo code: MASONPATRIOTS2021 tha applies a $10 discount on the rate. 4. If any given customer had an accident, the final calculated price for them is increased by 20 percent. Also, the promo code is not applied. ite a function that provides a quote for a given driver, based on the rules listed above. The function ameters are price of the car, age of the driver and whether the driver has had any history of accidents; | the promo code. If the promo code is correct, the discount is applied. Otherwise, no discount is lied. Finally, the function should calculate and return the following value: The final monthly rate rounded to 2 decimal places. created by Kourosh T. Baghaei e function signature is as follows: :MonthlyRate(price, age, accident, promocode) return monthlyRate

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I am having difficulties returning my function's final rate in an if-else statement. I did the code but when I run the program in terminal it is not giving me my output. 

my code is below and the instructions are after. 

input ()
price
age = input(O
аccident
1
%3D
input ()
("MASONPATRIOTS2021")
promocode
def calcMonthlyRate(price, age, accident, promocode):
4
6.
rate = 0
if price < 10000:
#base_monthlyrate = (5/10)*100
rate = price * (.5/100)
elif price >= 10000 and price < 250000:
#base_monthlyrate
7
8
9.
10
11
(1/100) * 100
12
rate =
price * (1.0 / 100.0)
elif price <= 25000:
#base_monthlyrate
rate = price * (2.0/100)
if age >= 18 and age < 25:
13
14
(2/100)* 100
15
16
17
rate = rate
discount_applied
elif age >= 25 and age < 40:
18
= 0
19
20
rate = rate - (5/100)*rate
21
elif age >= 40 and age <60:
22
rate = rate -
(10/100)* rate
23
elif age >= 60:
rate = rate - (15/100)* rate
if promocode == 'MASONPATRIOTS2021' and accident ==
24
25
'no':
26
rate = rate - 10
print (promocode)
else:
rate = rate + (.2 * 100)* rate
27
28
29
30
return rate
calcMonthlyRate(price, age, accident, promocode)
MonthlyRate
return round (MonthlyRate, 2)
31
%3D
32
33
34
35
36
37
Transcribed Image Text:input () price age = input(O аccident 1 %3D input () ("MASONPATRIOTS2021") promocode def calcMonthlyRate(price, age, accident, promocode): 4 6. rate = 0 if price < 10000: #base_monthlyrate = (5/10)*100 rate = price * (.5/100) elif price >= 10000 and price < 250000: #base_monthlyrate 7 8 9. 10 11 (1/100) * 100 12 rate = price * (1.0 / 100.0) elif price <= 25000: #base_monthlyrate rate = price * (2.0/100) if age >= 18 and age < 25: 13 14 (2/100)* 100 15 16 17 rate = rate discount_applied elif age >= 25 and age < 40: 18 = 0 19 20 rate = rate - (5/100)*rate 21 elif age >= 40 and age <60: 22 rate = rate - (10/100)* rate 23 elif age >= 60: rate = rate - (15/100)* rate if promocode == 'MASONPATRIOTS2021' and accident == 24 25 'no': 26 rate = rate - 10 print (promocode) else: rate = rate + (.2 * 100)* rate 27 28 29 30 return rate calcMonthlyRate(price, age, accident, promocode) MonthlyRate return round (MonthlyRate, 2) 31 %3D 32 33 34 35 36 37
UVICHI DCSTIiptivIT
Car insurance company XYZ considers various factors for calculating the price of their products for th
stomers. The sales team has decided to provide certain discounts to attract more customers. They woul
e to adjust the price according to the following table of information:
1. The base monthly rate is calculated as follows:
Price of The Car
Base Monthly Rate
0.5% of the price
1% of the price
2% of the price
10k and below
10k to 25k
25k and over
2. Based on the age of the driver, the following discounts are offered on the base monthly rate:
Discount Applied
Age
18 - 25
25 - 40
40 - 60
60 and over
0%
5 %
10 %
15 %
3. For students attending GMU, they have considered a promo code: MASONPATRIOTS2021 tha
applies a $10 discount on the rate.
4. If any given customer had an accident, the final calculated price for them is increased by 20
percent. Also, the promo code is not applied.
ite a function that provides a quote for a given driver, based on the rules listed above. The function
ameters are price of the car, age of the driver and whether the driver has had any history of accidents;
1 the promo code. If the promo code is correct, the discount is applied. Otherwise, no discount is
olied. Finally, the function should calculate and return the following value:
The final monthly rate rounded to 2 decimal places.
o created by Kourosh T. Baghaei
e function signature is as follows:
cMonthlyRate(price, age, accident, promocode)
return monthlyRate
Transcribed Image Text:UVICHI DCSTIiptivIT Car insurance company XYZ considers various factors for calculating the price of their products for th stomers. The sales team has decided to provide certain discounts to attract more customers. They woul e to adjust the price according to the following table of information: 1. The base monthly rate is calculated as follows: Price of The Car Base Monthly Rate 0.5% of the price 1% of the price 2% of the price 10k and below 10k to 25k 25k and over 2. Based on the age of the driver, the following discounts are offered on the base monthly rate: Discount Applied Age 18 - 25 25 - 40 40 - 60 60 and over 0% 5 % 10 % 15 % 3. For students attending GMU, they have considered a promo code: MASONPATRIOTS2021 tha applies a $10 discount on the rate. 4. If any given customer had an accident, the final calculated price for them is increased by 20 percent. Also, the promo code is not applied. ite a function that provides a quote for a given driver, based on the rules listed above. The function ameters are price of the car, age of the driver and whether the driver has had any history of accidents; 1 the promo code. If the promo code is correct, the discount is applied. Otherwise, no discount is olied. Finally, the function should calculate and return the following value: The final monthly rate rounded to 2 decimal places. o created by Kourosh T. Baghaei e function signature is as follows: cMonthlyRate(price, age, accident, promocode) return monthlyRate
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY