# 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.
Submitted by Shivang Yadav, on March 01, 2021

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%.

In this program, we will use the if-else ladder to calculate different discounts.

Code:

```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.

Preparation

What's New

Top Interview Coding Problems/Challenges!