The fashion gallery- a leading garments shop wants to develop an application in python to calculate the discount amount and net amount when bill amount is provided as input. The provided bill must be displayed on the screen.
The discount is given on the basis on payment mode: cash – 10.0%, cheque – 8.0% and credit – 5.0% of bill amount. If bill amount is more than 10000 then additional 5% discount is also given.
(python program.)
Answers
def discount_calc(payment_mode, amt):
discount_dict = {"cash": .1, "cheque": .08, "credit": .05}
discount_amt = amt * discount_dict[payment_mode]
net_amt = amt - discount_amt
if amt <= 10000:
return {"discount_amt": discount_amt, "net_amt": net_amt}
additional_discount = net_amt * .05
new_net_amt = net_amt - additional_discount
return {"discount_amt": additional_discount, "net_amt": new_net_amt}
while True:
payment_mode, amt = input("payment_mode: "), float(input("amt: "))
payment_modes = ["cash", "cheque", "credit"]
if payment_mode not in payment_modes:
print("Valid payment modes", ", ".join(payment_modes))
continue
else:
print()
for k, v in discount_calc(payment_mode, amt).items():
print(f"{k}: {v}")
break
Answer:
UsingPython3
∣
def discount_calc(payment_mode, amt):
discount_dict = {"cash": .1, "cheque": .08, "credit": .05}
discount_amt = amt * discount_dict[payment_mode]
net_amt = amt - discount_amt
if amt <= 10000:
return {"discount_amt": discount_amt, "net_amt": net_amt}
additional_discount = net_amt * .05
new_net_amt = net_amt - additional_discount
return {"discount_amt": additional_discount, "net_amt": new_net_amt}
while True:
payment_mode, amt = input("payment_mode: "), float(input("amt: "))
payment_modes = ["cash", "cheque", "credit"]
if payment_mode not in payment_modes:
print("Valid payment modes", ", ".join(payment_modes))
continue
else:
print()
for k, v in discount_calc(payment_mode, amt).items():
print(f"{k}: {v}")
break