human
Number of sub arrays with odd sum | Python 3 proggram to find count of sub - arrays with odd sum.
A temporary array of size 2. temp [ 0 ] is going to store count of even subarrays and temp [ 1 ] count of odd . temp [ 0 ] is initialized as 1 because there is a single odd element is also counted as a subarray.
Initialize count . sum is sum of elements under modulo 2 and ending with arr [ i ] ..
i ' th ▁ iteration ▁ computes ▁ ▁ sum ▁ of ▁ arr [ 0 . . i ] ▁ under ▁ ▁ modulo ▁ 2 ▁ and ▁ increments ▁ ▁ even / odd ▁ count ▁ according ▁ ▁ to ▁ sum ' s value.
2 is added to handle negative numbers.
Increment even / odd count.
An odd can be formed by even - odd pair.
Driver code"
How can the above be solved in Python?

=====
Give me a code to number of sub arrays with odd sum and the other steps required?
assistant
#Here is code to number of sub arrays with odd sum and the other steps required.
 def countOddSum ( ar , n ) :
	temp = [ 1 , 0 ]
	result = 0
	val = 0
	for i in range ( n ) :
		val = ( ( val + ar [ i ] ) % 2 + 2 ) % 2
		temp [ val ] += 1
	result = ( temp [ 0 ] * temp [ 1 ] )
	return ( result )
ar = [ 5 , 4 , 4 , 5 , 1 , 3 ]
print ( " The ▁ Number ▁ of ▁ Subarrays " " ▁ with ▁ odd ▁ sum ▁ is ▁ " + str ( countOddSum ( ar , 6 ) ) )