human
Calculate the loss incurred in selling the given items at discounted price | Function to return the x % of n.
Function to return the total loss.
To store the total loss.
Original price of the item.
The price at which the item will be sold.
The discounted price of the item.
Loss incurred.
Driver code.
Total items"
How can the above be solved in Python?
 Write me a code to calculate the loss incurred in selling the given items at discounted price and the other steps required?
assistant
#Here is code to calculate the loss incurred in selling the given items at discounted price and the other steps required.
 def percent ( n , x ) :
	p = ( int ) ( n ) * x ;
	p /= 100 ;
	return p ;
def getLoss ( price , quantity , X , n ) :
	loss = 0 ;
	for i in range ( n ) :
		originalPrice = price [ i ] ;
		sellingPrice = originalPrice + percent ( originalPrice , X [ i ] ) ;
		afterDiscount = sellingPrice - percent ( sellingPrice , X [ i ] ) ;
		loss += ( ( originalPrice - afterDiscount ) * quantity [ i ] ) ;
	return round ( loss , 2 ) ;
price = [ 20 , 48 , 200 , 100 ] ;
quantity = [ 20 , 48 , 1 , 1 ] ;
X = [ 0 , 48 , 200 , 5 ] ;
n = len ( X ) ;
print ( getLoss ( price , quantity , X , n ) ) ;