human
Count pairs in an array containing at least one even value | Function to count the pairs in the array such as there is at least one even element in each pair.
Store count of even and odd elements.
Check element is even or odd.
Driver Code"
How can the above be solved in Python?
 Give me a code to count pairs in an array containing at least one even value and the other steps required?
assistant
#Here is code to count pairs in an array containing at least one even value and the other steps required.
 def CountPairs ( arr , n ) :
	even = 0
	odd = 0
	for i in range ( n ) :
	if ( arr [ i ] % 2 == 0 ) :
		even += 1
	else :
		odd += 1
	return ( ( even * ( even - 1 ) ) // 2 + ( even * odd ) )
arr = [ 8 , 2 , 3 , 1 , 4 , 2 ]
n = len ( arr )
print ( CountPairs ( arr , n ) )