8.Write a Python program to calculate profit-loss for a given Cost and Sell Price and also find profit percentage and Loss Percentage.

Solution :- 

Static :- 

sp = 500
cp = 500

if sp > cp :
profit = sp-cp
profit_per = (profit * 100)//cp
print(“The Profit is :- “,profit)
print(“The Profit percentage is :- “,profit_per)
elif sp <cp:
loss = cp – sp
loss_per = (loss * 100)//cp
print(“The Loss is :- “,loss)
print(“The Loss percentage is :- “,loss_per)
else:
print(“No Profit No Loss”)

Output :- 

 

Dynamic :- 

sp = float(input(“Enter the Selling Price :- “))
cp = float(input(“Enter the Cost Price :- “))

if sp > cp :
profit = sp-cp
profit_per = (profit * 100)//cp
print(“The Profit is :- “,profit)
print(“The Profit percentage is :- “,profit_per)
elif sp <cp:
loss = cp – sp
loss_per = (loss * 100)//cp
print(“The Loss is :- “,loss)
print(“The Loss percentage is :- “,loss_per)
else:
print(“No Profit No Loss”)

Output :-