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.

Python Basic Programs »





Comments and Discussions




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.