human
Sum of even values and update queries on an array | Function to return the sum of even elements after updating value at given index.
Add given value to A [ index ].
To store the sum of even elements.
If current element is even.
Function to print result for every query.
Resultant vector that stores the result for every query.
Get sum of even elements after updating value at given index.
Store sum for each query.
Print the result for every query.
Driver code"
How can the above be solved in Python?
 Write me a code to sum of even values and update queries on an array and the other steps required?
assistant
#Here is code to sum of even values and update queries on an array and the other steps required.
 def EvenSum ( A , index , value ) :
	A [ index ] = A [ index ] + value
	sum = 0
	for i in A :
		if ( i % 2 == 0 ) :
			sum = sum + i
	return sum
def BalanceArray ( A , Q ) :
	ANS = [ ]
	i , sum = 0 , 0
	for i in range ( len ( Q ) ) :
		index = Q [ i ] [ 0 ]
		value = Q [ i ] [ 1 ]
		sum = EvenSum ( A , index , value )
		ANS . append ( sum )
	for i in ANS :
		print ( i , end = " ▁ " )
A = [ 1 , 2 , 3 , 4 ]
Q = [ [ 0 , 1 ] , [ 1 , - 3 ] , [ 0 , - 4 ] , [ 3 , 2 ] ]
BalanceArray ( A , Q )