human
Find the deleted value from the array when average of original elements is given | Function to return the missing element.
Find the sum of the array elements.
The numerator and the denominator of the equation.
If not divisible then X is not an integer it is a floating ponumber.
Return X.
Driver code"
How can the above be solved in Python?
 ... Give me a code to find the deleted value from the array when average of original elements is given and the other steps required?
assistant
#Here is code to find the deleted value from the array when average of original elements is given and the other steps required.
 def findMissing ( arr , n , k , avg ) :
	sum = 0 ;
	for i in range ( n ) :
		sum += arr [ i ] ;
	num = ( avg * ( n + k ) ) - sum ;
	den = k ;
	if ( num % den != 0 ) :
		return - 1 ;
	return ( int ) ( num / den ) ;
k = 3 ; avg = 4 ;
arr = [ 2 , 7 , 3 ] ;
n = len ( arr ) ;
print ( findMissing ( arr , n , k , avg ) ) ;