human
Number of subarrays having even product | Function to count subarrays with even product.
Stores count of subarrays with even product.
Traverse the array.
Initialize product.
Update product of the subarray.
Print total count of subarrays.
Driver Code.
Input.
Length of an array.
Function call to count subarrays with even product"
How can the above be solved in Python?
assistant
#Here is code to number of subarrays having even product and the other steps required.
 def evenproduct ( arr , length ) :
	count = 0 ;
	for i in range ( length + 1 ) :
		product = 1 ;
		for j in range ( i , length + 1 ) :
		product *= arr [ j ] ;
		if ( product % 2 == 0 ) :
			count += 1 ;
	print ( count ) ;
if __name__ == " _ _ main _ _ " :
	arr = [ 7 , 5 , 4 , 9 ] ;
	length = len ( arr ) - 1 ;
	evenproduct ( arr , length ) ;