Python program to check if profit or loss


Write a program in python input cost price and selling price of product and check if profit or loss and also print it.

cp=float(input("Enter the cost price of product : "))

sp=float(input("Enter the Selling price of product : "))

if cp==sp:

    print("No Profit No Loss")

else:

    if sp>cp:

        print("Profit of product is : ",sp-cp)

    else:

        print("Loss of product is : ",cp-sp)


Output :-

Enter the cost price of product : 550

Enter the Selling price of product : 800

Profit of product is :  250.0

-----------------------------------

Enter the cost price of product : 550

Enter the Selling price of product : 450

Loss of product is :  100.0

-----------------------------------

Enter the cost price of product : 500

Enter the Selling price of product : 500

No Profit No Loss


Post a Comment

0 Comments