human
Construct array with sum of product of same indexed elements in the given array equal to zero | Function to generate a new array with product of same indexed elements with arr [ ] equal to 0.
Stores sum of same indexed array elements of arr and new array.
Traverse the array.
If i is an even number.
Insert arr [ i + 1 ] into the new array newArr [ ].
Insert - arr [ i - 1 ] into the new array newArr [ ].
Print new array elements.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to construct array with sum of product of same indexed elements in the given array equal to zero and the other steps required.
 def constructNewArraySumZero ( arr , N ) :
	newArr = [ 0 ] * N
	for i in range ( N ) :
		if ( i % 2 == 0 ) :
			newArr [ i ] = arr [ i + 1 ]
		else :
			newArr [ i ] = - arr [ i - 1 ]
	for i in range ( N ) :
		print ( newArr [ i ] , end = " ▁ " )
arr = [ 1 , 2 , 3 , - 5 , - 6 , 8 ]
N = len ( arr )
constructNewArraySumZero ( arr , N )