human
Can you provide a code to find XOR of all elements in an Array and the other steps required given the following:
Find XOR of all elements in an Array | Function to find the XOR of all elements in the array.
Resultant variable.
Iterating through every element in the array.
Find XOR with the result.
Return the XOR.
Driver Code.
Function call"
How can the above be solved in Python?
assistant
#Here is code to find XOR of all elements in an Array and the other steps required.
 def xorOfArray ( arr , n ) :
	xor_arr = 0
	for i in range ( n ) :
		xor_arr = xor_arr ^ arr [ i ]
	return xor_arr
if __name__ == ' _ _ main _ _ ' :
	arr = [ 3 , 9 , 12 , 13 , 15 ]
	n = len ( arr )
	print ( xorOfArray ( arr , n ) )