Profit Calculation Using Python
In this tutorial, we try to demonstrate how to write a simple program in python to calculate profit for the following scenario
A shop owner buys a product at a price and sells it for a price in number of quantities. Write a console application in python to output the following
- Unit Profit (Profit by selling one unit of product)
- Total Sales Amount
- Total Cost of Product
- Total profit by Sales
- There is a discount if the quantity sold over 10. State whether the sale is eligible for discount or not.
Source code of Profit Calculation Using Python
#Getting Input from User print("Enter the Buying Price") buyingPrice = float(input()) print("Enter the Selling Price") sellingPrice = float(input()) print("Enter the No. of Quantities Sold") quantity = float(input()) # Unit Profit unitProfit = sellingPrice - buyingPrice print("Unit Profit is Rs.", unitProfit) # Total Sales totalSale = sellingPrice * quantity print("Total Sales is Rs.", totalSale) # Total Cost totalCost = buyingPrice * quantity print("Total Cost is Rs.", totalCost) # Total Profit profit = totalSale - totalCost print("Total Profit is Rs.", profit) # Check Eligibility if quantity >= 10: print("Eligible for Discount") else: print("Not Eligible for Discount")
You can use online python interpreter if you haven’t configured python on your computer.
The above code will produce the output as follows
You can download the source code here
To execute the above code, Open CMD and make sure you are in the directory where your file is. Then run the below code