Python program to calculate discount based on selling price

Here, we are going to write a Python program to calculate discount based on selling price.
By Shivang Yadav Last updated : January 13, 2024

Problem statement

Write a Python program to calculate discount based on selling price.

The discount will be calculated as,

  • If the order amount is greater than 100000 is 20%.
  • If the order amount is greater than 50000 and smaller than 100000 is 10%.
  • If the order amount is smaller than 50000 is 5%.

Calculate discount based on selling price

To calculate discount based on selling price, you can use the if-else ladder to calculate different discounts.

Python program to calculate discount based on selling price

rate = float(input("Enter Rate : "))
quantity = float(input("Enter Quantity : "))

amount = rate*quantity
print("Amount = ",amount)

if(amount >= 100000):
    discount = 20
elif(amount>=50000 and amount<=99999):
   discount = 10
else:
   discount = 5

discountAmount = (amount*discount)/100
netAmt = amount - discountAmount

print("Discount = %d%% and Discount Amount = %.2f"%(discount,discountAmount))

print("Net Amount = ",netAmt)

Output

Enter Rate : 500
Enter Quantity : 200
Amount =  100000.0
Discount = 20% and Discount Amount = 20000.00
Net Amount =  80000.0

In the above code, we have taken inputs from users for values of rate and quantity of the product. And the calculate amount by multiplying both using which we have calculated the discount percentage using which the values of discount amount and net payable amount is calculated.

To understand the above program, you should have the basic knowledge of the following Python topics:

Python Basic Programs »


Related Programs

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.