# Python Program to Calculate Profit or Loss

Write a Python Program to Calculate Profit or Loss with a practical example.

## Python Program to Calculate Profit or Loss using Elif Statement

This python program allows the user to enter the Sales amount and Actual cost of a Product. Next, Python calculates the Loss Amount or profit Amount based on those two values using Elif Statement.

```# Python Program to Calculate Profit or Loss

actual_cost = float(input(" Please Enter the Actual Product Price: "))
sale_amount = float(input(" Please Enter the Sales Amount: "))

if(actual_cost > sale_amount):
amount = actual_cost - sale_amount
print("Total Loss Amount = {0}".format(amount))
elif(sale_amount > actual_cost):
amount = sale_amount - actual_cost
print("Total Profit = {0}".format(amount))
else:
print("No Profit No Loss!!!")```

Python profit or loss output

`````` Please Enter the Actual Product Price: 1500
Please Enter the Sales Amount: 1200
Total Loss Amount = 300.0``````

Let me try different values

```if(actual_cost > sale_amount):
amount = actual_cost - sale_amount
print("Total Loss Amount = {0}".format(amount))
elif(sale_amount > actual_cost):
amount = sale_amount - actual_cost
print("Total Profit = {0}".format(amount))
else:
print("No Profit No Loss!!!")```
• If condition checks whether the actual cost is greater than the sale amount. If True, then Python prints the loss amount as actual cost – sales amount
• Elif statement checks whether the sale amount is greater than the actual cost. If True, it prints the profit amount as sales amount – actual cost
• If the above conditions fail, it means No Profit No Loss.

## Python Program to find Profit or Loss using Arithmetic Operator

In this profit or loss python program, we are using a Minus operator.

```# Python Program to Calculate Profit or Loss

actual_cost = float(input(" Please Enter the Actual Product Price: "))
sale_amount = float(input(" Please Enter the Sales Amount: "))

if(actual_cost - sale_amount > 0):
amount = actual_cost - sale_amount
print("Total Loss Amount = {0}".format(amount))
elif(sale_amount - actual_cost > 0):
amount = sale_amount - actual_cost
print("Total Profit = {0}".format(amount))
else:
print("No Profit No Loss!!!")```

Here, we tried all the possibilities and the Python profit or loss program output is

`````` Please Enter the Actual Product Price: 2200
Please Enter the Sales Amount: 6500
Total Profit = 4300.0
>>>
Please Enter the Actual Product Price: 9800
Please Enter the Sales Amount: 7200
Total Loss Amount = 2600.0
>>>
Please Enter the Actual Product Price: 1495
Please Enter the Sales Amount: 1495
No Profit No Loss!!!``````