Python program to find the sale price of an item with given cost and discount

Python program to find sale price of an item with given cost and discount

Selling price is actually the price that a customer pays in order to buy a product or services or goods. The basic formula to find the selling price used is as follows:

Selling price = cost price – Discount

Solved Examples

Example:

Sumedh offers a discount of 10% on the cost price of tv unit . TV unit price is 35000 .What is selling price of TV unit?

Solution:

Let the cost price of the TV unit be 35000.

Now, the Selling price = Cost price – Discount

= 35000– 10% of 35000

= 35000 – 3500

=31500

Program Logic:

  1. Input the cost price of TV unit using input method
  2. Ask user to enter the discount in percentage on cost price of TV unit using input method
  3. Calculate discount amount on cost price using formula : discount = cp * ds/100 where cp is cost price and ds is discount in percentage
  4. Calculate selling price by using formula : selling price = cost price – discount
  5. Display cost price,discount amount and selling price using print method

Below is implementation code

" Python program to find selling price with given cost and discount"
# Input cost price of product
cp=float(input("Enter Cost Price : "))
# Input discount in percentages on cost price
ds=float(input("Enter discount % : "))
# Calculating discount on cost price
discountamt=cp*ds/100
# Calculating selling price
sp=cp-discountamt
print("Cost Price : ",cp)
print("Discount: ",discountamt)
print("Selling Price : ",sp)

Below is output

>> %Run prog1.py
Enter Cost Price : 35000
Enter discount % : 10
Cost Price :  35000.0
Discount:  3500.0
Selling Price :  31500.0

In the above code, we have taken inputs from users for values of cost price and discount in percentage. And the calculate selling price of product by subtracting discount amount which we have calculated on cost price using stated formula (see in program) and selling price is calculated.

<