human
Program to find parity | Function to get parity of number n . It returns 1 if n has odd parity , and returns 0 if n has even parity.
Driver program to test getParity ( )"
How can the above be solved in Python?
 ... Give me a code to program to find parity and the other steps required?
assistant
#Here is code to program to find parity and the other steps required.
 def getParity ( n ) :
	parity = 0
	while n :
		parity = ~ parity
		n = n & ( n - 1 )
	return parity
n = 7
print ( " Parity ▁ of ▁ no ▁ " , n , " ▁ = ▁ " , ( " odd " if getParity ( n ) else " even " ) )