Programming Examples
Python program to check where is profit or loss
Write a python program to input cost price, selling price of product from user and check whether is profit or loss and also print the Profit/loss amount
Solution
cp=float(input("Enter the Cost Price : "));
sp=float(input("Enter the Selling Price : "));
if cp==sp:
print("No Profit No Loss")
else:
if sp>cp:
print("Profit of ",sp-cp)
else:
print("Loss of ",cp-sp)
Output/ Explanation:
Enter the Cost Price : 300
Enter the Selling Price : 450
Profit of 150.0
>>>
=========================
Enter the Cost Price : 500
Enter the Selling Price : 379
Loss of 121.0
>>>
=========================
Enter the Cost Price : 400
Enter the Selling Price : 400
No Profit No Loss