human
Find cost price from given selling price and profit or loss percentage | Function to calculate cost price with profit.
required formula to calculate CP with profit.
Function to calculate cost price with loss.
required formula to calculate CP with loss.
Driver code"
Solution in Python:
 ... Can you provide a code to find cost price from given selling price and profit or loss percentage and the other steps required?
assistant
#Here is code to find cost price from given selling price and profit or loss percentage and the other steps required.
 def CPwithProfit ( sellingPrice , profit ) :
	costPrice = ( ( sellingPrice * 100.0 ) / ( 100 + profit ) )
	return costPrice
def CPwithLoss ( sellingPrice , loss ) :
	costPrice = ( ( sellingPrice * 100.0 ) / ( 100 - loss ) )
	return costPrice
if __name__ == ' _ _ main _ _ ' :
	SP = 1020
	profit = 20
	print ( " Cost ▁ Price ▁ = " , CPwithProfit ( SP , profit ) )
	SP = 900
	loss = 10
	print ( " Cost ▁ Price ▁ = " , CPwithLoss ( SP , loss ) )
	SP = 42039
	profit = 8
	print ( " Cost ▁ Price ▁ = " , int ( CPwithProfit ( SP , profit ) ) )